All Products
Search
Document Center

ALTER TABLEGROUP

Last Updated: Jun 18, 2021

Description

You can execute the ALTER TABLEGROUP statement to perform the following operations:

  • Add multiple tables to a table group.
  • Modify partition rules for a table group.
  • Modify the locality and primary zone for a table group.

Syntax

  • Add multiple tables to a table group.
ALTER TABLEGROUP tablegroupname ADD [TABLE] tblname [, tblname…]
  • Modify partition rules for 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 primary zone for 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

Parameters

Parameter

Description

tablegroupname

The name of the table group.

tblname

The name of the table. To add multiple tables to a table group, separate table names with commas (,).

If you add multiple tables at a time, you can specify duplicate table names.

If the table you want to add exists in the specified table group, the system does not return an error.

modify_tg_partition_info

Modify the partition rules for the table group.

LOCALITY locality_name

The locality of the table group.

PRIMARY_ZONE primary_zone_name

The primary zone of the table group.

Examples

Create table group tgh and two relational tables ttgh and ttgh2, and 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)