OceanBase ALTER TABLEGROUP
2021-06-28 13:47 更新
描述
该语句用来执行以下操作:
-
对一个表组增加多张表。
-
修改表组的分区规则。
-
修改表组的 Locality 和 Primary Zone。
格式
-
对一个表组增加多张表。
ALTER TABLEGROUP tablegroupname ADD [TABLE] tblname [, tblname…]
-
修改表组的分区规则。
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
-
修改表组的 Locality 和 Primary Zone。
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
参数解释
参数 |
描述 |
---|---|
tablegroupname |
指定表组。 |
tblname |
表名。对一个表组增加多张表时,表与表之间以逗号(‘,’)分隔。 当添加多个表时,允许表名重复。如果待添加的表已经属于 |
modify_tg_partition_info |
修改表组的分区规则。 |
LOCALITY locality_name |
指定表组的 Locality。 |
PRIMARY_ZONE primary_zone_name |
指定表组的主 Zone。 |
示例
-
创建表组
tgh
,并将表组的Locality
修改为F@z1
,并创建两张关系表ttgh1
和ttgh2
。
obclient>CREATE TABLEGROUP tgh LOCALITY='F,R{ALL_SERVER}@z1' PARTITION BY HASH PARTITIONS 10;
Query OK, 0 rows affected (0.09 sec)
obclient>SELECT LOCALITY FROM sys.all_virtual_tablegroup_agent WHERE tablegroup_name ='TGH';
+------------------------------------+
| LOCALITY |
+------------------------------------+
| FULL{1},READONLY{ALL_SERVER}@1 |
+------------------------------------+
1 row in set (0.01 sec)
obclient>ALTER TABLEGROUP tgh SET LOCALITY ='F@z1';
Query OK, 0 rows affected (0.09 sec)
obclient>SELECT LOCALITY FROM sys.all_virtual_tablegroup_agent WHERE tablegroup_name ='TGH';
+------------+
| LOCALITY |
+------------+
| FULL{1}@z1 |
+------------+
1 row in set (0.05 sec)
obclient>SELECT LOCALITY FROM sys.all_virtual_tablegroup_agent WHERE tablegroup_id=(SELECT tablegroup_id FROM sys.all_virtual_tablegroup_agent WHERE tablegroup_name ='TGH');
+---------------+
| LOCALITY |
+---------------+
| FULL{1}@z1 |
+---------------+
1 row in set (0.00 sec)
obclient>CREATE TABLE ttgh1(c1 INT, c2 INT) TABLEGROUP = tgh LOCALITY='F@z1' PARTITION BY HASH(c1) PARTITIONS 10;
Query OK, 0 rows affected (0.55 sec)
obclient>CREATE TABLE ttgh2(c1 INT, c2 INT) TABLEGROUP = tgh LOCALITY='F@z1' PARTITION BY HASH(c1) PARTITIONS 10;
Query OK, 0 rows affected (0.39 sec)
以上内容是否对您有帮助:
更多建议: