User Tools

Site Tools


database:oracle:plsql-naming-conventions

Oracle PL/SQL Naming Conventions

  1. Variables:
    • Local: prefix with l_ (e.g., l_counter).
    • Global: prefix with g_ (for those declared in a package specification).
  2. Parameters:
    • Prefix with p_ (e.g., p_emp_id).
  3. Cursors:
    • Prefix with cur_ (e.g., cur_employee).
  4. Constants:
    • Prefix with c_ (e.g., c_max_value).
    • Uppercase for constants (e.g., MAX_VALUE).
  5. Types:
    • Prefix with t_ (e.g., t_employee_table for a table type).
  6. Exception:
    • Prefix with ex_ or err_ (e.g., ex_no_data).
  7. Records:
    • Suffix with _rec or _type (e.g., employee_rec).
  8. Arrays/Collections:
    • Suffix with _tbl or _list (e.g., employee_list or employee_tbl).
  9. Procedures/Functions:
    • Procedures: use verbs (e.g., update_employee, calculate_bonus).
    • Functions: names reflecting return value (e.g., get_employee_salary).
  10. Boolean variables:
    • Prefix with is_, has_, or can_ (e.g., is_valid, has_records).
  11. 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).
  12. Indexes:
    • Prefix with idx_ (e.g., idx_emp_name).
  13. Triggers:
    • Reflect timing and event (e.g., before_insert_emp).
  14. 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