W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
該語(yǔ)句用來(lái)創(chuàng)建表組。
說(shuō)明
只有租戶下的管理員權(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 |
表組名稱,最長(zhǎng) 64 個(gè)字符,字符只能有大小寫(xiě)英文字母,數(shù)字和下劃線,而且必須以字母或下劃線開(kāi)頭,并且不能使用 OceanBase 的關(guān)鍵字。 如果要?jiǎng)?chuàng)建的表組名稱已存在,并且沒(méi)有指定 IF NOT EXISTS,則會(huì)出現(xiàn)錯(cuò)誤。 |
opt_tablegroup_option_list |
表組的分區(qū)方式、locality、primary zone 必須和組內(nèi)的表完全一致。 組內(nèi)的表信息不能獨(dú)立變更某一項(xiàng),只可以通過(guò)操作表組進(jìn)行批量操作。 相同的 locality:副本類(lèi)型、個(gè)數(shù)、位置要完全一致 相同的 primary zone:leader 位置及其優(yōu)先級(jí)要完全一致 相同的分區(qū)方式:
|
opt_tg_partition_option |
表組的分區(qū)規(guī)則定義,與 CREATE TABLE 使用同樣的分區(qū)方式。 表組沒(méi)有具體的列定義,所以 HASH、RANGE、LIST 不需要寫(xiě)出具體的列,只需要指定列個(gè)數(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,同時(shí)創(chuàng)建 hash 分區(qū)的表 ttgh,且分區(qū)個(gè)數(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號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: