Character Sets and Collations of Expressions of the String Type
Each expression of the string type contains character sets and collation attributes. The default character sets and collations of string constants are determined by the system parameters character_set_connection and collation_connection.
Character set syntax:
1
|
[_charset_name]'string' |
Syntax description:
charset_name
Specifies a character set and parses a string expression following it. charset_name is set to a valid character set name.
Example:
1 2 |
-- Specify a character set and parse a string expression following it. m_db=# select _utf8'GaussDB'; |
Collation syntax:
You can also specify the collation for expressions of other character string types.
1
|
expression [COLLATE collation_name] |
Syntax description:
COLLATE collation_name
Collation name, which is the collation attribute of the string. The specified collation must be supported by the character set of the expression. The data type of the expression must be a data type that supports collations.
Example:
1 2 |
-- Use the collate statement to specify the collation. m_db=# SELECT 'a' COLLATE utf8mb4_general_ci = 'A'; |
If it is not supported, it is implicitly converted to the character string type. If there is no implicit conversion path, an error is reported.
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