Table operations

2023-12-25 08:49:41  Updated

In the Oracle mode of OceanBase Database, you can change the row format, block size, and name of a table.

Change the row format

The syntax for changing the row format is as follows:

ALTER TABLE table_name [MOVE]
 {  NOCOMPRESS
  | COMPRESS [BASIC]
  | COMPRESS FOR OLTP
  | COMPRESS FOR QUERY [LOW | HIGH]
  | COMPRESS FOR ARCHIVE [LOW | HIGH]
  };

The parameters are described 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 lz4_1.0 algorithm.
  • COMPRESS FOR QUERY [LOW | HIGH]: Data is encoded, saved in the encoding format, and compressed by using the zstd_1.0 algorithm.
  • COMPRESS FOR ARCHIVE: Data is encoded, saved in the encoding format, and compressed by using the zstd_1.0 algorithm. By default, COMPRESS FOR ARCHIVE is used.

Here is an example:

obclient> ALTER TABLE t1 MOVE NOCOMPRESS;
Query OK, 0 rows affected

Change the block size

The syntax for changing the block size is as follows:

ALTER TABLE table_name BLOCK_SIZE = value;

Here is an example:

obclient> ALTER TABLE t1 BLOCK_SIZE = 1024;
Query OK, 0 rows affected

Rename a table

The syntax for renaming a table is as follows:

ALTER TABLE old_tbl_name RENAME TO new_tbl_name;

Here is an example:

obclient> ALTER TABLE t1 RENAME TO t2;
Query OK, 0 rows affected

Contact Us