OceanBase supports MySQL and Oracle tenants. To facilitate the use in MySQL or Oracle mode, OceanBase Database provides multiple configuration methods for you to use data encoding and data compression.
MySQL mode
In MySQL mode, you can set the default_row_format parameter to specify whether to encode data when you create a table. The valid values of this parameter include:
REDUNDANT and COMPAT: Data is not encoded and is saved in the row format.
DYNAMIC and COMPRESSED: Data is encoded. The default value is DYNAMIC.
You can set the default_compress_func parameter to specify the data compression algorithm. The following code provides an example:
obclient>ALTER SYSTEM SET default_compress_func='zlib_1.0';
Alternatively, you can specify whether to encode data when you create a table. The following code provides an example:
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=compressed;
Oracle mode
In Oracle mode, you can set the default_compress parameter to specify the system default encoding and compression options. The valid values of this parameter include:
NOCOMPRESS: Data is not encoded or compressed.
BASIC: Data is not encoded and is compressed by using lz4_1.0.
OLTP: Data is not encoded and is compressed by using zstd_1.0.
QUERY: indicates that the data will be encoded and will be compressed by using lz4_1.0.
ARCHIVE: indicates that the data will be encoded and will be compressed by using zstd_1.0. The default value is ARCHIVE.
The following is a configuration example:
obclient> ALTER SYSTEM SET default_compress='NOCOMPRESS';
You can specify the encoding and compression options when you create a table. Example:
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 high;