OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.3.3

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & Certification
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.3.3
    iconOceanBase Database
    SQL - V 4.3.3
    SQL
    KV
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Character sets and collations for client connection

    Last Updated:2024-12-02 03:48:26  Updated
    share
    What is on this page
    System variables of character sets and collations
    Configure SQL statements for client character sets

    folded

    share

    A connection refers to the session established when a client connects to a server for interactions. The client sends SQL statements, such as queries, by using the connection. The server sends responses, such as result sets and error messages, back to the client by using the connection.

    System variables of character sets and collations

    The following character set and collation system variables are related to the client-server interaction:

    • The character_set_server and collation_server variables specify the character set and collation of the server.

    • The character_set_database and collation_database variables specify the default character set and collation for the database.

    The server also uses the following system variables:

    • character_set_client specifies the character set in which the statements are sent by the client.

    • character_set_connection specifies the character set to which received statements are converted. The server converts the character set of the statement sent by the client from character_set_client to character_set_connection.

    • collation_connection specifies the character set and collation used by the connection. collation_connection is crucial for string comparison.

    • character_set_results specifies the character set for the server to return query results to the client, including data results (such as column values), metadata (such as column names), and error messages. If you do not need to convert result sets or error messages, set character_set_results to NULL or binary by using the following syntax:

      SET character_set_results = NULL;
      SET character_set_results = binary;
      

    To view all character set and collation system variables, execute the following statements:

    obclient> SHOW SESSION VARIABLES LIKE 'character\_set\_%';
    +--------------------------+---------+
    | Variable_name            | Value   |
    +--------------------------+---------+
    | character_set_client     | latin1  |
    | character_set_connection | latin1  |
    | character_set_database   | utf8mb4 |
    | character_set_filesystem | binary  |
    | character_set_results    | latin1  |
    | character_set_server     | utf8mb4 |
    | character_set_system     | utf8mb4 |
    +--------------------------+---------+
    7 rows in set
    
    obclient> SHOW SESSION VARIABLES LIKE 'collation\_%';
    +----------------------+--------------------+
    | Variable_name        | Value              |
    +----------------------+--------------------+
    | collation_connection | latin1_swedish_ci  |
    | collation_database   | utf8mb4_general_ci |
    | collation_server     | utf8mb4_general_ci |
    +----------------------+--------------------+
    3 rows in set
    

    Configure SQL statements for client character sets

    After it establishes the connection, the client can change the character set and collation system variables of the current session. Execute the following SET statements:

    • SET NAMES 'charset_name'

      This statement specifies the character set that the client uses in subsequent requests. It is equivalent to the following three statements:

      SET character_set_client = charset_name;
      SET character_set_results = charset_name;
      SET character_set_connection = charset_name;
      

      To specify a collation for collation_connection, add a COLLATE clause:

      SET NAMES 'charset_name' COLLATE 'collation_name'
      
    • SET CHARACTER SET 'charset_name'

      This statement is similar to SET NAMES, but it sets character_set_connection and collation_connection to the default values of the character_set_database and collation_database. It is equivalent to the following three statements:

      SET character_set_client = charset_name;
      SET character_set_results = charset_name;
      SET collation_connection = @@collation_database;
      

    Previous topic

    Character sets and collations for character expressions
    Last

    Next topic

    Overview
    Next
    What is on this page
    System variables of character sets and collations
    Configure SQL statements for client character sets