Skip to main content

SET NAMES

Description

Sets the client, connection, and result character sets and collations.

Syntax

SET NAMES charset_name [COLLATE collation_name]

Parameters

ParameterDescription
charset_nameThe default character set for the columns in the table. Valid values:
  • binary
  • utf8mb4
  • gbk
  • utf16
  • gb18030
collation_nameThe default collation for the columns in the table. Valid values:
  • binary
  • gbk_bin
  • gbk_chinese_ci
  • utf8mb4_general_ci
  • utf8mb4__general_cs
  • utf8mb4_bin
  • utf8mb4_unicode_ci
  • utf16_general_ci
  • utf16_bin
  • utf16_unicode_ci
  • gb18030_chinese_ci
  • gb18030_bin

Examples

Set the client, connection, and result character sets to gbk and the collations to gbk_bin.

SET NAMES gbk COLLATE gbk_bin;
Query OK, 0 rows affected (0.126 sec)