语法
SET {CHARACTER SET | CHARSET} {'charset_name' | DEFAULT}
其中,charset_name
可不加引号。
示例
mysql> 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) mysql> SET CHARSET 'big5'; Query OK, 0 rows affected (0.06 sec) mysql> 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 | +--------------------------+--------+