OceanBase Database supports two methods for table compression. One method is to compress tables by using data encoding, and the other is to compress tables by using general algorithms such as lz4_1.0 and zstd_1.0.
When you create a table or modify the attributes of a table in an OceanBase database, you can set the ROW_FORMAT parameter to specify whether to enable data encoding. You can also set the COMPRESSION attribute to specify the compression algorithm to be used.
Disable or enable data encoding
Disable data encoding by using the
ROW_FORMATparameter. The SQL syntax is as follows:CREATE TABLE table_name ROW_FORMAT = REDUNDANT; ALTER TABLE table_name [SET] ROW_FORMAT = REDUNDANT; CREATE TABLE table_name ROW_FORMAT = COMPACT; ALTER TABLE table_name [SET] ROW_FORMAT = COMPACT;Enable data encoding by using the
ROW_FORMATparameter. The SQL syntax is as follows:CREATE TABLE table_name ROW_FORMAT = DYNAMIC; ALTER TABLE table_name [SET] ROW_FORMAT = DYNAMIC; CREATE TABLE table_name ROW_FORMAT = COMPRESSED; ALTER TABLE table_name [SET] ROW_FORMAT = COMPRESSED; CREATE TABLE table_name ROW_FORMAT = CONDENSED; ALTER TABLE table_name [SET] ROW_FORMAT = CONDENSED; CREATE TABLE table_name ROW_FORMAT = DEFAULT; ALTER TABLE table_name [SET] ROW_FORMAT = DEFAULT;
Specify the compression algorithm
The SQL syntax for specifying the compression algorithm by using the COMPRESSION attribute is as follows:
CREATE TABLE table_name COMPRESSION 'compress_func_name';
ALTER TABLE table_name [SET] COMPRESSION 'compress_func_name';
You can set the compress_func_name parameter to none, zstd_1.0, or lz4_1.0. The value none specifies that no compression algorithm is to be used.
For more information, see Compression and encoding.