| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| database:oracle:plsql-naming-conventions [2023/09/08 17:36] – ↷ Page name changed from database:oracle:procedure-naming-conventions to database:oracle:plsql-naming-conventions odefta | database:oracle:plsql-naming-conventions [2025/01/02 18:22] (current) – external edit 127.0.0.1 |
|---|
| |
| - **Variables**: | - **Variables**: |
| - Local: prefix with ''l_'' (e.g., ''l_counter''). | * Local: prefix with ''l_'' (e.g., ''l_counter''). |
| - Global: prefix with ''g_'' (for those declared in a package specification). | * Global: prefix with ''g_'' (for those declared in a package specification). |
| - **Parameters**: | - **Parameters**: |
| - Prefix with ''p_'' (e.g., ''p_emp_id''). | * Prefix with ''p_'' (e.g., ''p_emp_id''). |
| - **Cursors**: | - **Cursors**: |
| - Prefix with ''cur_'' (e.g., ''cur_employee''). | * Prefix with ''cur_'' (e.g., ''cur_employee''). |
| - **Constants**: | - **Constants**: |
| - Prefix with ''c_'' (e.g., ''c_max_value''). | * Prefix with ''c_'' (e.g., ''c_max_value''). |
| - Uppercase for constants (e.g., ''MAX_VALUE''). | * Uppercase for constants (e.g., ''MAX_VALUE''). |
| - **Types**: | - **Types**: |
| - Prefix with ''t_'' (e.g., ''t_employee_table'' for a table type). | * Prefix with ''t_'' (e.g., ''t_employee_table'' for a table type). |
| - **Exception**: | - **Exception**: |
| - Prefix with ''ex_'' or ''err_'' (e.g., ''ex_no_data''). | * Prefix with ''ex_'' or ''err_'' (e.g., ''ex_no_data''). |
| - **Records**: | - **Records**: |
| - Suffix with ''_rec'' or ''_type'' (e.g., ''employee_rec''). | * Suffix with ''_rec'' or ''_type'' (e.g., ''employee_rec''). |
| - **Arrays/Collections**: | - **Arrays/Collections**: |
| - Suffix with ''_tbl'' or ''_list'' (e.g., ''employee_list'' or ''employee_tbl''). | * Suffix with ''_tbl'' or ''_list'' (e.g., ''employee_list'' or ''employee_tbl''). |
| - **Procedures/Functions**: | - **Procedures/Functions**: |
| - Procedures: use verbs (e.g., ''update_employee'', ''calculate_bonus''). | * Procedures: use verbs (e.g., ''update_employee'', ''calculate_bonus''). |
| - Functions: names reflecting return value (e.g., ''get_employee_salary''). | * Functions: names reflecting return value (e.g., ''get_employee_salary''). |
| - **Boolean variables**: | - **Boolean variables**: |
| - Prefix with ''is_'', ''has_'', or ''can_'' (e.g., ''is_valid'', ''has_records''). | * Prefix with ''is_'', ''has_'', or ''can_'' (e.g., ''is_valid'', ''has_records''). |
| - **Tables/Views**: | - **Tables/Views**: |
| - Tables: use plural names (e.g., ''employees''). | * Tables: use plural names (e.g., ''employees''). |
| - Views: prefix with ''v_'' or suffix with ''_view'' (e.g., ''v_active_employees'', ''employee_summary_view''). | * Views: prefix with ''v_'' or suffix with ''_view'' (e.g., ''v_active_employees'', ''employee_summary_view''). |
| - **Indexes**: | - **Indexes**: |
| - Prefix with ''idx_'' (e.g., ''idx_emp_name''). | * Prefix with ''idx_'' (e.g., ''idx_emp_name''). |
| - **Triggers**: | - **Triggers**: |
| - Reflect timing and event (e.g., ''before_insert_emp''). | * Reflect timing and event (e.g., ''before_insert_emp''). |
| - **Packages**: | - **Packages**: |
| - Name based on functionality (e.g., ''pkg_employee_operations''). | * Name based on functionality (e.g., ''pkg_employee_operations''). |
| |
| <note> | **Note:** The key to effective naming is consistency. Always apply your chosen conventions uniformly. |
| The key to effective naming is consistency. Always apply your chosen conventions uniformly. | |
| </note> | |
| |