13.7.6.3 SET NAMES Statement语句

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

This statement sets the three session system variables character_set_client, character_set_connection, and character_set_results to the given character set. 此语句将三个会话系统变量character_set_clientcharacter_set_connectioncharacter_set_results设置为给定的字符集。Setting character_set_connection to charset_name also sets collation_connection to the default collation for charset_name. character_set_connection设置为charset_name也会将collation_connection设置为charset_name的默认排序规则。See Section 10.4, “Connection Character Sets and Collations”.请参阅第10.4节,“连接字符集和排序规则”

The optional COLLATE clause may be used to specify a collation explicitly. 可选的COLLATE子句可用于显式指定排序规则。If given, the collation must one of the permitted collations for charset_name.如果给定,则排序规则必须是charset_name允许的排序规则之一。

charset_name and collation_name may be quoted or unquoted.可以是带引号的,也可以是不带引号的。

The default mapping can be restored by using a value of DEFAULT. 可以使用DEFAULT恢复默认映射。The default depends on the server configuration.默认值取决于服务器配置。

Some character sets cannot be used as the client character set. 某些字符集不能用作客户端字符集。Attempting to use them with SET NAMES produces an error. 尝试将它们与SET NAMES一起使用会产生错误。See Impermissible Client Character Sets.请参阅不允许的客户端字符集