database:oracle:plsql-naming-conventions
Oracle PL/SQL Naming Conventions
- Variables:
- Local: prefix with
l_
(e.g.,l_counter
). - Global: prefix with
g_
(for those declared in a package specification).
- Parameters:
- Prefix with
p_
(e.g.,p_emp_id
).
- Cursors:
- Prefix with
cur_
(e.g.,cur_employee
).
- Constants:
- Prefix with
c_
(e.g.,c_max_value
). - Uppercase for constants (e.g.,
MAX_VALUE
).
- Types:
- Prefix with
t_
(e.g.,t_employee_table
for a table type).
- Exception:
- Prefix with
ex_
orerr_
(e.g.,ex_no_data
).
- Records:
- Suffix with
_rec
or_type
(e.g.,employee_rec
).
- Arrays/Collections:
- Suffix with
_tbl
or_list
(e.g.,employee_list
oremployee_tbl
).
- Procedures/Functions:
- Procedures: use verbs (e.g.,
update_employee
,calculate_bonus
). - Functions: names reflecting return value (e.g.,
get_employee_salary
).
- Boolean variables:
- Prefix with
is_
,has_
, orcan_
(e.g.,is_valid
,has_records
).
- Tables/Views:
- Tables: use plural names (e.g.,
employees
). - Views: prefix with
v_
or suffix with_view
(e.g.,v_active_employees
,employee_summary_view
).
- Indexes:
- Prefix with
idx_
(e.g.,idx_emp_name
).
- Triggers:
- Reflect timing and event (e.g.,
before_insert_emp
).
- Packages:
- Name based on functionality (e.g.,
pkg_employee_operations
).
Note: The key to effective naming is consistency. Always apply your chosen conventions uniformly.
database/oracle/plsql-naming-conventions.txt · Last modified: 2023/09/08 20:38 by odefta