G-9204
🆓Warning
Always follow naming conventions for primary key constraints.
Reason
All table constraints share the same namespace. Furthermore the name of the primary key constraint is used by default as index name. 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
Table name or table abbreviation followed by the suffix _pk
.
Examples
employees_pk
departments_pk
sct_contracts_pk
Example
Non-Compliant Example
create table emp ( empno number(4,0) not null, -- ... constraint emp#primary#key primary key (empno) );
Issues
Line | Column | Message |
---|---|---|
4 | 15 |
★★★★★
Compliant Solution -
create table emp ( empno number(4,0) not null, -- ... constraint emp_pk primary key (empno) );
Parameters
Use parameters to customize the rule to your needs.
Parameter | Description | Default Value |
---|---|---|
PrimaryKeyConstraintPattern | Case-insensitive regular expression pattern for SQL primary key constraints. | ^[a-z][a-z0-9$#_]_pk$ |