This topic provides recommendations for naming other objects in OceanBase Database to help developers standardize the naming of relevant database objects.
Index naming
This section describes the recommended naming conventions for common indexes, unique indexes, primary keys, and foreign keys.
Common indexes
Use the format "idx_+table name (or abbreviation)+column name (or abbreviation)", for example, "idx_dept_deptno".
UNIQUE constraints
Use the format "uk_+table name (or abbreviation)+column name (or abbreviation)", for example, "uk_dept_deptno".
PRIMARY KEY constraints
Use the format "pk_+table name (or abbreviation)+_+primary key field", for example, "pk_dept_deptno".
FOREIGN KEY constraints
Use the format "fk_+table name (or abbreviation)++main table name (or abbreviation)++primary key field", for example, "fk_teacher_student_id".
View naming
Use the format "v_+table name (or abbreviation)+column name (or abbreviation)", for example, "v_dept_deptno".
Synonym naming
Use the format "syn_+table name (or abbreviation)", for example, "syn_temp".
Trigger naming
Triggers can be divided into AFTER, BEFORE, and INSTEAD OF triggers by feature. Name triggers based on their features.
AFTER triggers
Use the format "tr_+table name (or abbreviation)+_+aft+column name (or abbreviation)", for example, "tr_dept_aft_deptno".
BEFORE triggers
Use the format "tr_+table name (or abbreviation)++bef+column name (or abbreviation)", for example, "tr_dept_bef_deptno".
INSTEAD OF triggers
Use the format "tr_+table name (or abbreviation)+_+ins+column name (or abbreviation)", for example, "tr_dept_ins_deptno".
Stored procedure naming
Use the format "proc_+table name (or abbreviation)" or "proc_+feature name (or abbreviation)", for example, "proc_temp" or "proc_out".
Function naming
Use the format "function name (or abbreviation)", for example, "GetLineNo()", "SetLineNo()".
Notice
Function names should follow camelCase.
Sequence naming
Use the format "seq_+table name (or abbreviation)+column name (or abbreviation)", for example, "seq_dept_deptno".