All Products
Search
Document Center

PolarDB:SET CHARACTER SET

Last Updated:Mar 27, 2026

Sets the character set for the current client session, controlling how the client sends data to and receives data from the server.

SET CHARACTER SET updates three session variables:

  • character_set_client: set to charset_name

  • character_set_results: set to charset_name

  • character_set_connection: set to the current value of character_set_database, not charset_name

Syntax

SET {CHARACTER SET | CHARSET}
    {'charset_name' | DEFAULT}

charset_name can be quoted or unquoted. CHARSET is an alias for CHARACTER SET.

Example

The example below shows session variable values before and after running SET CHARSET 'big5'.

Before

SHOW SESSION VARIABLES LIKE 'character\_set\_%';
+--------------------------+---------+
| Variable_name            | Value   |
+--------------------------+---------+
| character_set_client     | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database   | utf8    |
| character_set_filesystem | binary  |
| character_set_results    | utf8mb4 |
| character_set_server     | utf8    |
| character_set_system     | utf8    |
+--------------------------+---------+
7 rows in set (0.01 sec)

After

SET CHARSET 'big5';
Query OK, 0 rows affected (0.06 sec)

SHOW SESSION VARIABLES LIKE 'character\_set\_%';
+--------------------------+--------+
| Variable_name            | Value  |
+--------------------------+--------+
| character_set_client     | big5   |
| character_set_connection | utf8   |
| character_set_database   | utf8   |
| character_set_filesystem | binary |
| character_set_results    | big5   |
| character_set_server     | utf8   |
| character_set_system     | utf8   |
+--------------------------+--------+
7 rows in set (0.21 sec)

character_set_client and character_set_results are set to big5. character_set_connection is set to utf8, the current value of character_set_database, not big5.