Database Object Naming Guidelines
- The name of a database object must contain up to 63 characters, start with a letter or underscore (_), and can contain letters, digits, underscores (_), dollar signs ($), and number signs (#).
- Do not use reserved or non-reserved keywords to name database objects.
Run the following command to view the keywords:
SELECT * FROM pg_get_keywords();
- Do not use a string enclosed in double quotation marks ("") to define the database object name, unless you need to specify its capitalization.
By default, GaussDB is case insensitive for object names in SQL statements. If two different tables (t_Table and t_table) exist in the same database, use double quotation marks (""). Otherwise, avoid using double quotation marks (""). Case sensitivity of database object names makes problem location difficult.
- The naming style of database objects must be consistent. Lowercase letters are recommended.
In a system undergoing incremental development or service migration, comply with its historical naming conventions.
Use multiple words separated with underscores (_).
Use intelligible names and common acronyms or abbreviations for database objects. Acronyms or abbreviations that are generally understood are recommended, for example, use English words or Chinese pinyin indicating actual business terms. The naming format should be consistent within a DB instance.
A variable name must be descriptive and meaningful. It must have a prefix indicating its type.
Table 1 Naming rules of database objects Object Type
Prefix
Example
Length Restriction
(Unit: Byte)
Remarks
Database name
db__
db_businessname
<=63
/
Common table
t_
t_tablename
<=63
/
Temporary table
tmp_
tmp_tablename
<=63
For example, an intermediate table used by operation personnel for temporary backup or data collection.
Naming rule: tmp_Table name abbreviation_Creator account abbreviation_Creation date, for example, tmp_user_ytw_160505.
Primary key
pk_
pk_tablename
<=63
If the table name is too long, use the abbreviation of the table name. Use the universal abbreviation or the abbreviation without vowels.
UNIQUE constraint
uk_
uk_tablename_columnname
<=63
Unique index, which is named uk_.
If the table name or field name is too long, use the abbreviation of the table name or field name. Use the universal abbreviation or the abbreviation without vowels.
Function
f_
f_functionname
<=63
/
Table field
/
/
<=63
Use meaningful English words or abbreviations to name fields.
For example, a field of the bool type is named in the format of is_Description. A column whose member status is enabled in the member table is named is_enabled.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot