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.1.0

    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.1.0
    iconOceanBase Database
    SQL - V 4.1.0
    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

    Overview

    Last Updated:2023-07-28 02:55:42  Updated
    share
    What is on this page
    Character data types
    Character set overview
    UNICODE character set
    Database character set
    National character set

    folded

    share

    The character data types store character (alphanumeric) data, which are words and free-form text, in the database character set or the national character set. Compared with other data types, character data types are less restrictive, and therefore have fewer attributes. This topic describes character data types and character sets supported by OceanBase Database.

    Character data types

    Character data is stored in strings whose byte values correspond to one of the character sets specified when the database was created. OceanBase Database supports single-byte and multi-byte character sets.

    Note

    A column of the character data type can store all alphanumeric values. However, a column of the NUMBER data type can store only numeric values.

    The following table describes the data types supported by OceanBase Database.

    Data type
    Length type
    Usage notes
    Length
    CHAR(size [BYTE CHAR]) Fixed This data type features high index efficiency. You can use trim to remove excess blanks in a program. The value range of the size parameter is [1,2000]. The default and minimum values are 1. The storage size is specified by size, in bytes or characters.
    NCHAR[(size)] Fixed This data type uses the UNICODE character set. Each character requires two bytes of storage. The value range of the size parameter is [1,2000]. The default and minimum values are 1. The storage size is twice the value specified by size, in bytes.
    NVARCHAR2(size) Variable This data type uses the UNICODE character set. Each character requires two bytes of storage. The value range of the size parameter is [1,32767]. The byte storage size is twice the number of characters entered.
    VARCHAR2(size [BYTE CHAR]) Variable This data type uses the UNICODE character set. Each character requires two bytes of storage. The value range of the size parameter is [1,32767]. The storage size is the actual length of the bytes or characters entered, rather than the value specified by size in bytes or characters.
    VARCHAR(size [BYTE CHAR]) Variable In OceanBase Database, VARCHAR and VARCHAR2 are the same. The value range of the size parameter is [1,32767]. The storage size is the actual length of the bytes entered, rather than the value specified by size, in bytes.

    Note

    For CHAR and VARCHAR2 data types, you must specify length, whose default value is specified by the system variable NLS_LENGTH_SEMANTICS.

    Character set overview

    UNICODE character set

    UNICODE is a character set that can be encoded using one of the following encoding schemes: UTF-8, UTF-16, and UTF-32. UNICODE data can also be compressed and converted. Encodings determine the amount of storage space needed to store a character. Chinese and English characters require different amount of storage space in different storage modes.

    The following table describes the encoding methods.

    Encoding method
    Code unit size
    BOM
    Advantages
    Disadvantages
    UTF-8 A variable-width encoding that can be single-byte (ASCII characters) or multi-byte (nonASCII characters), with a minimum code unit of 8 bits. Without BOM: A text that starts with EF BB BF is an UTF-8-encoded text file. An ideal UNICODE encoding: fully compatible with ASCII, no BOM, strong self-synchronization and error correction capabilities, suitable for network data transmission, and high scalability. Variable-length encoding is not convenient for the internal processing of text in programs.
    UTF-16 A 2-byte or 4-byte encoding, with a minimum code unit of 16 bits. With BOM: UTF-16LE (little endian) is represented by FF FE and UTF-16BE (big endian) is represented by FE FF. The earliest Unicode encoding that has been widely used in various environments, suitable for processing Unicode data in memory, and a way to encode strings in APIs in many programming languages. Incompatible with ASCII, complex encoding (because it uses surrogate pairs to encode code points from supplementary planes), and poor scalability.
    UTF-32 A fixed 4-byte encoding, with a minimum code unit of 16 bits. With BOM: UTF-16LE (little endian) is represented by FF FE and UTF-16BE (big endian) is represented by FE FF. Easy to read as a fixed-byte encoding, suitable for use in internal processing, every Unicode code point matches a single code unit. A waste of space and bandwidth because all characters are encoded using 4 bytes, incompatible with ASCII, poor scalability, and rarely used.

    Database character set

    The database character set can be used in the following ways:

    • Stores data types such as CHAR, VARCHAR2, and CLOB.

    • Indicates table names, column names, and PL variables.

    • Stores SQL and PL storage units.

    National character set

    The national character set stores data types such as NCHAR, NVARCHAR2, and NCLOB.

    The national character set is an alternative character set selected for OceanBase Database. The NCHAR data type provides another character set choice in addition to the database character set provided by the CHAR data type, thereby enhancing the character processing capability of OceanBase Database.

    Previous topic

    Overview
    Last

    Next topic

    CHAR data type
    Next
    What is on this page
    Character data types
    Character set overview
    UNICODE character set
    Database character set
    National character set