Character Types
Table 1 lists the character types supported by GaussDB. For string operators and related built-in functions, see Character Processing Functions and Operators.
Name |
Description |
Storage Space |
---|---|---|
CHAR(n) CHARACTER(n) NCHAR(n) |
Fixed-length character string, blank padded. n indicates the string length. If it is not specified, the default precision 1 is used. |
The maximum value of n is 10485760 (10 MB). |
When sql_compatibility is set to 'MYSQL', if b_format_version is set to '5.7' and b_format_dev_version is set to 's1':
|
The value contains a maximum of 10M characters. |
|
VARCHAR(n) CHARACTER VARYING(n) |
Variable-length string. In PG-compatible mode, n indicates the string length. In other compatibility modes, n indicates the byte length. |
The maximum value of n is 10485760 (10 MB). If n is not specified, the maximum storage length is 1 GB – 85 – Length of the first n columns. For example, the maximum length of (a int, b varchar) is 1,073,741,735 (= 1 GB – 85 – 4). |
When sql_compatibility is set to 'MYSQL', if b_format_version is set to '5.7' and b_format_dev_version is set to 's1':
|
If n is specified, the maximum storage length is 10 MB. If n is not specified, the maximum storage length is 1 GB – 85 – Length of the first n columns. For example, the maximum storage length of (a int, b varchar) is 1,073,741,735 (= 1 GB – 85 – 4). |
|
VARCHAR2(n) |
Variable-length string. It is the alias of the VARCHAR(n) type. |
The maximum value of n is 10485760 (10 MB). If n is not specified, the maximum storage length is 1 GB – 85 – Length of the first n columns. For example, the maximum length of (a int, b varchar) is 1,073,741,735 (= 1 GB – 85 – 4). |
NVARCHAR2(n) |
Variable-length string. In the SQL_ASCII character set, n indicates bytes. In the non-SQL_ASCII character set, n indicates characters. |
The maximum value of n is 10485760 (10 MB). If n is not specified, the maximum storage length is 1 GB – 85 – Length of the first n columns. For example, the maximum length of (a int, b varchar) is 1,073,741,735 (= 1 GB – 85 – 4). |
TEXT |
Variable-length string. |
The maximum size is 1 GB minus 1 byte. However, the size of the column description header and the size of the tuple (less than 1 GB minus 1 byte) where the column is located must also be considered. Therefore, the maximum size of the TEXT type may be less than 1 GB minus 1 byte. |
CLOB |
Big text object. |
For Ustore, the maximum size is 1 GB minus 1 byte. However, the size of the column description header and the size of the tuple (less than 1 GB minus 1 byte) where the column is located must also be considered. Therefore, the maximum size of the CLOB type may be less than 1 GB minus 1 byte. |
TINYTEXT MEDIUMTEXT LONGTEXT |
When sql_compatibility is set to 'MYSQL', if b_format_version is set to '5.7' and b_format_dev_version is set to 's1', these types can be used. Converts a data type to the TEXT type. The application scenario is the same as that of the TEXT type. |
The maximum size is 1 GB minus 1 byte. However, the size of the column description header and the size of the tuple (less than 1 GB minus 1 byte) where the column is located must also be considered. Therefore, the maximum size of the TEXT type may be less than 1 GB minus 1 byte. |
- In addition to the restriction on the size of each column, the total size of each tuple cannot exceed 1 GB minus 1 byte and is affected by the control header information of the column, the control header information of the tuple, and whether null fields exist in the tuple.
- NCHAR is the alias of the bpchar type, and VARCHAR2(n) is the alias of the VARCHAR(n) type.
- Only advanced package dbe_lob supports CLOBs whose size is greater than 1 GB. System functions do not support CLOBs whose size is greater than 1 GB.
- In A-compatible mode, the received empty string is converted to null by default.
Table 2 lists the two other fixed-length character types supported by GaussDB. The name type exists only for the storage of identifiers in the internal system catalogs and is not intended for use by general users. Its length is currently defined as 64 bytes (63 usable characters plus terminator). The char type uses only one byte of storage. It is internally used in the system catalogs as a simplistic enumeration type.
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