OceanBase SET NAMES

2021-06-29 14:38 更新

描述

該語句用來設(shè)置當(dāng)前連接的數(shù)據(jù)庫的字符集編碼。

格式

SET NAMES 'charset_name' [COLLATE 'collation_name']

參數(shù)解釋

參數(shù)

描述

charset_name

指定字符集

collation_name

指定字符集排序規(guī)則。如未指定,則使用字符集默認(rèn)排序規(guī)則。

說明 
該語句將三個會話系統(tǒng)變量? character_set_client ?, ?character_set_connection? 和 ?character_set_results? 設(shè)置為給定的字符集。將 ?character_set_connection? 設(shè)置為 ?charset_name ?,將 ?collation_connection?設(shè)置為 ?charset_name? 的默認(rèn)排序規(guī)則。

示例

  • 設(shè)置數(shù)據(jù)庫的字符集和排序規(guī)則。
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)
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號