Database Object Naming Specifications
- [Specification] Do not use reserved or non-reserved keywords to name database objects. You can run the following command to query the database keyword, or view it in the Keywords section:
SELECT * FROM pg_get_keywords();
- [Specification] The database object name contains a maximum of 63 bytes.
Table 1 Restriction on the length of database object names Object Type
Length Restriction
(Unit: Byte)
Remarks
Database name
≤ 63
-
Table name
≤ 63
-
Table object
≤ 63
If the length of a table name exceeds this value, the kernel truncates the table name. As a result, the actual name is inconsistent with the configured value. In addition, characters may be truncated in different character sets and unexpected characters may appear.
Temporary table not used by services
≤ 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.
Table column
≤ 63
Meaningful English words or abbreviations are used to name the column.
For example, a column 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.
View name and column name
≤ 63
-
Function name and parameter name
≤ 63
-
- [Rule] Do not use a string enclosed in double quotation marks ("") to define the database object name, unless you must 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 fault locating difficult.
- [Rule] Identifiers must meet the following requirements:
- An identifier starts with a letter or underscore (_) and can contain letters, digits, underscores (_), dollar signs ($), and number signs (#).
- If an identifier is enclosed in backquotes (``) in B-compatible mode or double quotation marks (""), any combination of valid characters can be used, for example, "123gs_column".
- Identifiers are case-insensitive unless they are enclosed in backquotes (``) in B-compatible mode or double quotation marks ("").
- [Recommendation] Do not use a string enclosed in double quotation marks ("") to define the database object name, unless you need to specify its capitalization. Case sensitivity of database object names makes fault locating difficult.
- [Recommendation] Use the same naming style for database objects.
- In a system undergoing incremental development or service migration, you are advised to comply with its historical naming conventions.
- You are advised to use multiple words separated with underscores (_).
- You are advised to use intelligible names and common acronyms or abbreviations for database objects. For example, you can use English words or Chinese pinyin indicating actual business terms. The naming format should be consistent within a database instance.
- A variable name must be descriptive and meaningful. It must have a prefix indicating its type.
- [Recommendation] The name of a table object should indicate its main characteristics, for example, whether it is an ordinary, temporary, or unlogged table.
- An ordinary table name should indicate the business relevant to a dataset.
- Temporary tables are named in the format of tmp_Suffix.
- Unlogged tables are named in the format of ul_Suffix.
- Foreign tables are named in the format of f_Suffix.
- Do not create database objects whose names start with redis_.
- Do not create database objects whose names start with mlog_ or matviewmap_.
- Do not create database objects whose names start with gs_role_.
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