SET NAMES

You can execute the SET NAMES statement to specify character sets. This statement sets character_set_client, character_set_connection, and character_set_results to the specified character set.

Syntax

SET NAMES {'charset_name'
[COLLATE 'collation_name'] | DEFAULT}

You do not need to enclose charset_name or collation_name in single quotation marks ('). If you specify the collation_name parameter, the collation is set to the specified value.

Examples

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.03 sec)

SET NAMES gb18030 COLLATE gb18030_chinese_ci;
Query OK, 0 rows affected (0.02 sec)

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

results matching ""

    No results matching ""