该语句用来设置当前连接的数据库的字符集编码。
SET NAMES 'charset_name' [COLLATE 'collation_name']
参数 | 描述 |
---|---|
charset_name | 指定字符集 |
collation_name | 指定字符集排序规则。如未指定,则使用字符集默认排序规则。 |
说明
该语句将三个会话系统变量character_set_client
, character_set_connection
和 character_set_results
设置为给定的字符集。将 character_set_connection
设置为 charset_name
,将 collation_connection
设置为 charset_name
的默认排序规则。
OceanBase(admin@test)>SET NAMES 'utf8mb4' COLLATE 'utf8mb4_general_ci';
Query OK, 0 rows affected (0.00 sec)
OceanBase(admin@test)>show variables like 'character_set_c%';
+--------------------------+---------+
| Variable_name | Value |
+--------------------------+---------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
+--------------------------+---------+
2 rows in set (0.01 sec)
OceanBase(admin@test)>show variables like 'collation_connection';
+----------------------+--------------------+
| Variable_name | Value |
+----------------------+--------------------+
| collation_connection | utf8mb4_general_ci |
+----------------------+--------------------+
1 row in set (0.05 sec)
OceanBase(admin@test)>SET NAMES 'gbk';
Query OK, 0 rows affected (0.02 sec)
OceanBase(admin@test)>show variables like 'character_set_c%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| character_set_client | gbk |
| character_set_connection | gbk |
+--------------------------+-------+
2 rows in set (0.01 sec)
OceanBase(admin@test)>show variables like 'collation_connection';
+----------------------+----------------+
| Variable_name | Value |
+----------------------+----------------+
| collation_connection | gbk_chinese_ci |
+----------------------+----------------+
1 row in set (0.01 sec)
备案信息: 粤ICP备15087711号-2
Copyright © 2008-2024 啊嘎哇在线工具箱 All Rights.
本站所有资料来源于网络,版权归原作者所有,仅作学习交流使用,如不慎侵犯了您的权利,请联系我们。