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

    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.3.1
    iconOceanBase Database
    SQL - V 4.3.1
    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

    Data encoding and compression

    Last Updated:2026-04-15 08:25:14  Updated
    share
    What is on this page
    Configure data compression and encoding in MySQL mode
    Configure data compression and encoding in Oracle mode
    Change the compression algorithm for SSTables

    folded

    share

    OceanBase Database supports both MySQL and Oracle modes. To accommodate users with different usage habits, OceanBase Database provides different configuration options for data encoding and compression in each mode.

    OceanBase Database supports the use of DDL statements to configure the encoding and compression of data tables.

    Configure data compression and encoding in MySQL mode

    When you create or modify a table in MySQL mode, you can set the row_format and compression parameters to specify the encoding format and compression algorithm.

    The SQL syntax is as follows:

    • Specify the encoding format and compression algorithm when you create the table

      CREATE TABLE table_name table_definition_list
      ROW_FORMAT [=] row_format COMPRESSION [=] 'compression';
      

      For more information about the CREATE TABLE statement, see CREATE TABLE.

    • Modify the encoding format and compression algorithm when you modify the table

      ALTER TABLE table_name [alter_table_action_list] [SET] ROW_FORMAT [=]row_format COMPRESSION [=]  'compression';
      

      For more information about the ALTER TABLE statement, see ALTER TABLE.

    Valid values of the row_format parameter are as follows:

    • REDUNDANT and COMPACT: Data is not encoded and is saved in the flat format.

    • DYNAMIC: Data is encoded and saved in the encoding format. The default value is DYNAMIC.

    • COMPRESSED: Data is encoded and saved in a new and more efficient encoding format.

    • CONDENSED: Data is encoded and saved in the selective encoding format.

      The selective encoding format is a subset of the encoding format and is more query-friendly.

    Valid values of the compression parameter are as follows:

    Note

    The zlib compression algorithm of different minor versions may generate different compression results for the same data. To avoid replica restore failures during an upgrade, the zlib_1.0 compression algorithm is no longer supported in OceanBase Database V4.3.0 and later.

    • none: Data is not compressed.

    • lz4_1.0: Data is compressed by using the lz4_1.0 algorithm.

    • snappy_1.0: Data is compressed by using the snappy_1.0 algorithm.

    • zstd_1.0: Data is compressed by using the zstd_1.0 algorithm.

    • zstd_1.3.8: Data is compressed by using the zstd_1.3.8 algorithm. By default, the zstd_1.3.8 algorithm is used.

    • lz4_1.9.1: Data is compressed by using the lz4_1.9.1 algorithm.

    Here are some examples:

    • Specify the encoding format and compression algorithm when you create the table

      Execute the following statement to set the encoding format to encoding and the compression algorithm to zstd_1.0 when you create a table:

      obclient> CREATE TABLE test (
       id INT NOT NULL,
       fname VARCHAR(30),
       lname VARCHAR(30),
       hired DATE NOT NULL DEFAULT '1970-01-01',
       separated DATE NOT NULL DEFAULT '9999-12-31',
       job_code INT NOT NULL,
       store_id INT NOT NULL
      ) ROW_FORMAT=CONDENSED COMPRESSION='zstd_1.0';
      
    • Modify the encoding format and compression algorithm when you modify the table

      Execute the following statement to change the encoding format to selective encoding and the compression algorithm to lz4_1.0:

      obclient> ALTER TABLE test SET ROW_FORMAT = CONDENSED COMPRESSION = 'lz4_1.0';
      

    Configure data compression and encoding in Oracle mode

    When you create or modify a table in Oracle mode, you can specify the data encoding format and compression algorithm.

    The SQL syntax is as follows:

    • Specify the encoding format and compression algorithm when you create the table

      CREATE TABLE table_name table_definition_list compression;
      

      For more information about the CREATE TABLE statement, see CREATE TABLE.

    • Modify the encoding format and compression algorithm when you modify the table

      ALTER TABLE table_name [alter_table_action_list] compression;
      

      For more information about the ALTER TABLE statement, see ALTER TABLE.

    Valid values of the compression parameter are as follows:

    • NOCOMPRESS: Data is not encoded or compressed, and is saved in the flat format.

    • COMPRESS BASIC: Data is not encoded but is saved in the flat format and compressed by using the lz4_1.0 algorithm.

    • COMPRESS FOR OLTP: Data is not encoded but is saved in the flat format and compressed by using the zstd_1.3.8 algorithm.

    • COMPRESS FOR QUERY: Data is encoded, saved in the encoding format, and compressed by using the lz4_1.0 algorithm.

    • COMPRESS FOR ARCHIVE: Data is encoded, saved in the encoding format, and compressed by using the zstd_1.3.8 algorithm. By default, COMPRESS FOR ARCHIVE is used.

    • COMPRESS FOR ARCHIVE HIGH: Data is encoded, saved in a new and more efficient encoding format, and compressed by using the zstd_1.3.8 algorithm.

    • COMPRESS FOR QUERY LOW: Data is encoded, saved in the selective encoding format, and compressed by using the lz4_1.0 algorithm.

      The selective encoding format is a subset of the encoding format and is more query-friendly.

    Here are some examples:

    • Specify the encoding format and compression algorithm when you create the table

      Execute the following statement to set the encoding format to encoding and the compression algorithm to lz4_1.0 when you create a table:

      obclient> CREATE TABLE test (
      id number NOT NULL,
      fname VARCHAR2(30),
      lname VARCHAR2(30),
      hired DATE NOT NULL DEFAULT sysdate,
      separated DATE,
      job_code INT NOT NULL,
      store_id INT NOT NULL
      ) COMPRESS FOR QUERY;
      
    • Modify the encoding format and compression algorithm when you modify the table

      Execute the following statement to change the table encoding format to encoding and the compression algorithm to zstd_1.3.8:

      obclient> ALTER TABLE test COMPRESS FOR ARCHIVE;
      

    Change the compression algorithm for SSTables

    To change the compression algorithm for SSTables without causing a huge volume of I/O writes in major compactions, you need to launch a progressive compaction to rewrite all the data microblocks. The number of rounds of progressive compactions can be determined by specifying the progressive_merge_num parameter in the ALTER TABLE statement.

    To do so, perform the following steps:

    1. Log on to the database as a tenant administrator.

    2. Execute the following statement to set the number of rounds of progressive compactions.

      The progressive_merge_num parameter specifies the number of rounds of progressive compactions on a table. The default value is 0, which indicates incremental compaction. If you set the parameter to 1, a full compaction is performed.

      To set two rounds of progressive compactions, execute the following statement:

      obclient> ALTER TABLE t1 SET progressive_merge_num=2;
      

      After the parameter is set, data is progressively rewritten during major compactions each day.

    Note

    To complete data rewriting at the earliest opportunity, you can set the progressive_merge_num to 1, and launch a major compaction. For more information about how to manually initiate a major compaction, see Manually initiate a major compaction.

    1. Change the compression algorithm.

      For more information about how to change the compression algorithm in MySQL mode, see Configure data compression and encoding in MySQL mode in this topic.

      For more information about how to change the compression algorithm in Oracle mode, see Configure data compression and encoding in Oracle mode in this topic.

    Previous topic

    Overview
    Last

    Next topic

    Overview
    Next
    What is on this page
    Configure data compression and encoding in MySQL mode
    Configure data compression and encoding in Oracle mode
    Change the compression algorithm for SSTables