rules repository

G-9201

🆓
Warning

Always follow naming conventions for tables.

Reason

SQL identifiers share the same namespace as PL/SQL identifiers. Follow naming conventions to prevent naming conflicts, improve readability, and clearly indicate the scope without forcing the use of qualified names. A common practice is to use a prefix and/or suffix to distinguish the identifier types.

Recommendations

Plural name of what is contained in the table (unless the table is designed to always hold one row only – then you should use a singular name).

Suffixed by _eb when protected by an editioning view.

Add a comment to the database dictionary for every table and every column in the table. See also G-1260 and G-1270.

Optionally prefixed by a project abbreviation.

Examples

  • employees
  • departments
  • countries_eb - table interfaced by an editioning view named countries
  • sct_contracts
  • sct_contract_lines
  • sct_incentive_modules

Why plural names?

We see a table and a view as a collection. A jar containing beans is labeled "beans". In Java we call such a collection also "beans" (List<Bean> beans) and name an entry "bean" (for (Bean bean : beans) {...}). An entry of a table is a row (singular) and a table can contain an unbounded number of rows (plural). This and the fact that the Oracle Database uses the same concept for their tables and views lead to the decision to use the plural to name a table or a view.

Example

Non-Compliant Example

create table départements (
   deptno number
   -- ...
);
Issues
LineColumnMessage
114table départements does not match '^[a-z0-9$#_]+'.

Explanation

We do not want accented letters in table names.

Compliant Solution - ★★★★★

create table departements (
   deptno number
   -- ...
);

Explanation

All accented letters are replaced with plain Latin letters.

Parameters

Use parameters to customize the rule to your needs.

ParameterDescriptionDefault Value
TablePatternCase-insensitive regular expression pattern for SQL tables.^[a-z][a-z0-9$#_]*$

References