database:oracle:plsql-naming-conventions
This is an old revision of the document!
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_tablefor a table type).
- Exception:
- Prefix with
ex_orerr_(e.g.,ex_no_data).
- Records:
- Suffix with
_recor_type(e.g.,employee_rec).
- Arrays/Collections:
- Suffix with
_tblor_list(e.g.,employee_listoremployee_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.1694194714.txt.gz · Last modified: (external edit)
