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_client
、character_set_connection
和character_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.请参阅不允许的客户端字符集。