Help Center/ GaussDB/ M-Compatibility Developer Guide(Distributed)/ SQL Reference/ Character Sets and Collations/ Character Sets and Collations of Expressions of the String Type
Updated on 2025-10-23 GMT+08:00

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'

Currently, the character set syntax for specifying string constants is not supported in 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 data type of the expression must be a data type that supports collations.
  • The specified collation must be supported by the character set of the expression.

Examples:

1
2
-- Use the collate statement to specify the collation.
m_db=# SELECT 'a' COLLATE utf8mb4_general_ci = 'A';