Table operations

2023-10-31 11:17:11  Updated

In MySQL mode of OceanBase Database, you can change the row format, change the block size, change the character set, and rename a table.

Change the row format

The syntax for changing the row format is as follows:

ALTER TABLE table_name ROW_FORMAT = {DEFAULT | DYNAMIC | FIXED | COMPRESSED | REDUNDANT | COMPACT};

Here is an example:

obclient> ALTER TABLE t1 ROW_FORMAT = COMPRESSED;
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

Change the character set

The syntax for changing the character set is as follows:

ALTER TABLE table_name CONVERT TO CHARACTER SET charset_name;

Here is an example:

obclient> ALTER TABLE test_collation CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
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