W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
該語句用來創(chuàng)建表組。
說明
只有租戶下的管理員權(quán)限才可以創(chuàng)建表組。
CREATE TABLEGROUP [IF NOT EXISTS] tablegroupname [opt_tablegroup_option_list] [opt_tg_partition_option]
opt_tablegroup_option_list:
tablegroup_option [tablegroup_option]
tablegroup_option:
LOCALITY [=] locality_name
| PRIMARY_ZONE [=] primary_zone_name
opt_tg_partition_option:
PARTITION BY
HASH COLUMN_NUM [tg_subpartition_option] PARTITIONS INTNUM
| RANGE COLUMNS COLUMN_NUM [tg_subpartition_option] {PARTITION partition_name VALUES LESS THAN range_partition_expr, ...}
| LIST COLUMNS COLUMN_NUM [tg_subpartition_option] {PARTITION partition_name VALUES in list_partition_expr, ...}
tg_subpartition_option:
SUBPARTITION BY
RANGE COLUMN_NUM SUBPARTITION TEMPLATE {SUBPARTITION partition_name VALUES LESS THAN range_partition_expr, ...}
| HASH COLUMN_NUM [SUBPARTITIONS INTNUM]
| LIST COLUMN_NUM SUBPARTITION TEMPLATE {SUBPARTITION partition_name VALUES in list_partition_expr, ...}
參數(shù) |
描述 |
---|---|
tablegroupname |
表組名稱,最長 64 個字符,字符只能有大小寫英文字母,數(shù)字和下劃線,而且必須以字母或下劃線開頭,并且不能使用 OceanBase 的關(guān)鍵字。 如果要創(chuàng)建的表組名稱已存在,并且沒有指定 IF NOT EXISTS,則會出現(xiàn)錯誤。 |
opt_tablegroup_option_list |
表組的分區(qū)方式、locality、primary zone 必須和組內(nèi)的表完全一致。 組內(nèi)的表信息不能獨立變更某一項,只可以通過操作表組進行批量操作。 相同的 locality:副本類型、個數(shù)、位置要完全一致 相同的 primary zone:leader 位置及其優(yōu)先級要完全一致 相同的分區(qū)方式:
|
opt_tg_partition_option |
表組的分區(qū)規(guī)則定義,與 CREATE TABLE 使用同樣的分區(qū)方式。 表組沒有具體的列定義,所以 HASH、RANGE、LIST 不需要寫出具體的列,只需要指定列個數(shù)(COLUMN_NUM)。 |
創(chuàng)建名為 myTableGroup1 的表組。
OceanBase(admin@test)> CREATE TABLEGROUP myTableGroup1;
Query OK, 0 rows affected (0.07 sec)
OceanBase(admin@test)> create table myt1 (c1 int, c2 int ) tablegroup = myTableGroup1;
Query OK, 0 rows affected (0.28 sec)
OceanBase(admin@test)> create table myt2 (c1 int, c2 int ) tablegroup = myTableGroup1;
Query OK, 0 rows affected (0.26 sec)
創(chuàng)建 hash 分區(qū)的表組 tgh,同時創(chuàng)建 hash 分區(qū)的表 ttgh,且分區(qū)個數(shù)相同。
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) locality='F,R{ALL_SERVER}@z1' partition by hash(c1) partitions 10;
Query OK, 0 rows affected (0.55 sec)
OceanBase(admin@test)> create table ttgh2(c1 int, c2 int) locality='F,R{ALL_SERVER}@z1' partition by hash(c2) partitions 10;
Query OK, 0 rows affected (0.39 sec)
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: