OceanBase logo

OceanBase

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

Product Overview
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

OceanBase

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

Product Overview
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.2.2

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    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.2.2
    iconOceanBase Database
    SQL - V 4.2.2
    SQL
    KV
    • V 4.6.0
    • 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 set specifications

    Last Updated:2026-04-15 08:27:14  Updated
    share
    What is on this page
    share

    This topic describes the character set selection specifications in OceanBase Database.

    You can set the character set at the tenant level, database level, table level, field level, or session level. Currently, OceanBase Database supports the utf8mb4, gbk, gb18030, binary, and utf16 character sets.

    Note

    • For seamless data migration, OceanBase Database considers UTF8 and UTF8MB4 to be synonyms in syntax.
    • You cannot change the character set of a database.

    For example, the following describes how to set the gbk character set:

    • Set the character set when creating a tenant

      • You can add the "charset=gbk" parameter to the create tenant statement.

        create tenant oracle replica_num = 1,
        resource_pool_list =('pool1'),
        charset = gbk
        set
          ob_tcp_invited_nodes = '%',
          ob_compatibility_mode = 'oracle',
          parallel_servers_target = 10,
          ob_sql_work_area_percentage = 20,
          secure_file_priv = "";
        
      • You can select the gbk character set when creating a tenant in the OCP console.

      Notice

      • In Oracle mode, the character set is tenant-level. In a gbk tenant, all char, varchar2, and clob columns of user tables use the gbk character set, while the char and varchar2 columns of system tables retain the utf8 character set.
      • You cannot modify the character set of an Oracle tenant.
    • Set the character set for a client (connection)

      • The character set for a client (connection) is the character set configured for interactions between the client (such as OBClient, JDBC, and OCI) and the server.

        The client sends SQL statements to the server for execution and receives the execution results from the server. The server needs to know the character set used by the client to correctly parse, execute, and return the results. Therefore, sometimes the character set for a client is also called the link character set.

      • The tenant character set and the client character set are independently configured.

        A tenant using the gbk character set can be connected to by clients using the gbk character set or utf8 character set.

        • If the client character set is gbk, the server will parse and execute the received SQL statement using the gbk character set.

        • If the client character set is utf8, the server will parse and execute the received SQL statement using the utf8 character set.

      • Configuration methods

        • Permanent modification

          set global character_set_client = gbk;
          set global character_set_connection = gbk;
          set global character_set_results = gbk;
          
          • character_set_client: the client character set.

          • character_set_connection: the connection character set. In Oracle mode, it is recommended to set this parameter to the same value as character_set_client.

          • character_set_results: the character set of the results returned from the server to the client.

            Generally, the character sets for strings sent from the client to the server and from the server to the client are the same. Therefore, in Oracle mode, it is recommended to set the three parameters to the same value; in MySQL mode, the three parameters can be flexibly configured. Generally, it is sufficient to set the three parameters to the client character set.

        • Temporary modification (effective only for the current session)

          • Method 1:

            set character_set_client = gbk;
            set character_set_connection = gbk;
            set character_set_results = gbk;
            
          • Method 2:

            set names gbk;
            
    • Set the client character set

      • When you use JDBC to connect to OceanBase Database, you can add the characterEncoding=gbk parameter to the URL.

        String url = "jdbc:oceanbase://xxx.xxx.xxx.xxx:xxxx?useSSL=false&useUnicode=true&characterEncoding=gbk&connectTimeout=30000&rewriteBatchedStatements=true";
        
      • When you use OBClient to connect to the database, we recommend that you use the superset zh_CN.GB18030 of the GBK character set for the bash environment variable.

        • Modify the bash environment variable

          export LANG=zh_CN.GB18030
          export LC_ALL=zh_CN.GB18030
          
        • Modify the encoding setting of your terminal and set the current window to the gbk encoding. Perform operations based on the instructions in the terminal interface.

      Notice

      Apart from configuring the GBK character set for the observer process (database), you must also configure the GBK character set for the client and driver. Otherwise, garbled characters may appear due to configuration errors.

    Previous topic

    Other structural designs
    Last

    Next topic

    Database connection specifications
    Next