All Products
Search
Document Center

ALTER TABLEGROUP

Last Updated: Jun 18, 2021

Description

This statement performs the following operations:

  • Add multiple tables to a table group.

  • Modify the partitioning rule of a table group.

  • Modify the locality and the primary zone of a table group.

Syntax

  • Add multiple tables to a table group.

ALTER TABLEGROUP tablegroupname ADD [TABLE] tblname [, tblname…]
  • Modify the partitioning rule of a table group.

ALTER TABLEGROUP tablegroupname alter_tg_partition_option
alter_tg_partition_option:
DROP PARTITION '(' name_list ')'
| ADD PARTITION opt_range_partition_list
| modify_tg_partition_info
  • Modify the locality and the primary zone of a table group.

ALTER TABLEGROUP tablegroupname alter_tablegroup_actions
alter_tablegroup_actions:
alter_tablegroup_action
| alter_tablegroup_action, alter_tablegroup_action
alter_tablegroup_action:
SET LOCALITY [=] locality_name
|SET PRIMARY_ZONE [=] primary_zone_name

Parameter description

Parameter

Description

tablegroupname

Specifies the table group.

tblname

The table name. If you add multiple tables to the table group, separate the tables with commas (,).

If you add multiple tables, duplicate table names are allowed. If the table to be added already exists in

the table group that is specified by tablegroupname , the system does not report an error.

modify_tg_partition_info

Modifies the partitioning rule of the table group.

LOCALITY locality_name

Specifies the locality of the table group.

PRIMARY_ZONE primary_zone_name

Specifies the primary zone of the table group.

Examples

  • Create the table group tgh and two relational tables ttgh and ttgh2. Change the locality of the table group to F@z1.

OceanBase(admin@test)> create tablegroup tgh locality='F,R{ALL_SERVER}@z1' partition by hash partitions 10;
Query OK, 0 rows affected (0.09 sec)

OceanBase(admin@test)> create table ttgh(c1 int, c2 int) tablegroup = tgh locality='F,R{ALL_SERVER}@z1';
Query OK, 0 rows affected (0.55 sec)

OceanBase(admin@test)> create table ttgh2(c1 int, c2 int) tablegroup = tgh locality='F,R{ALL_SERVER}@z1';
Query OK, 0 rows affected (0.39 sec)

OceanBase(admin@test)> alter tablegroup tgh set locality ='F@z1';
Query OK, 0 rows affected (0.09 sec)

OceanBase(admin@test)> select locality from oceanbase.__all_tablegroup where tablegroup_name ='tgh';
+------------+
| locality   |
+------------+
| FULL{1}@z1 |
+------------+
1 row in set (0.05 sec)

OceanBase(admin@test)> select locality from oceanbase.__all_table where tablegroup_id=(select tablegroup_id from oceanbase.__all_tablegroup where tablegroup_name ='tgh');
+------------+
| locality   |
+------------+
| FULL{1}@z1 |
| FULL{1}@z1 |
+------------+
2 rows in set (0.04 sec)