数据仓库服务 GAUSSDB(DWS)-CLUSTER:示例

时间:2024-03-30 16:52:45

示例

创建一个分区表:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
CREATE TABLE tpcds.inventory_p1
(
    INV_DATE_SK               INTEGER               NOT NULL,
    INV_ITEM_SK               INTEGER               NOT NULL,
    INV_WAREHOUSE_SK          INTEGER               NOT NULL,
    INV_QUANTITY_ON_HAND      INTEGER
)
DISTRIBUTE BY HASH(INV_ITEM_SK)
PARTITION BY RANGE(INV_DATE_SK)
(
        PARTITION P1 VALUES LESS THAN(2451179),
        PARTITION P2 VALUES LESS THAN(2451544),
        PARTITION P3 VALUES LESS THAN(2451910),
        PARTITION P4 VALUES LESS THAN(2452275),
        PARTITION P5 VALUES LESS THAN(2452640),
        PARTITION P6 VALUES LESS THAN(2453005),
        PARTITION P7 VALUES LESS THAN(MAXVALUE)
);

创建索引ds_inventory_p1_index1。

1
CREATE INDEX ds_inventory_p1_index1 ON tpcds.inventory_p1 (INV_ITEM_SK) LOCAL;

对表tpcds.inventory_p1进行聚集:

1
CLUSTER tpcds.inventory_p1 USING ds_inventory_p1_index1;

对分区p3进行聚集:

1
CLUSTER tpcds.inventory_p1 PARTITION (p3) USING ds_inventory_p1_index1;

对数据库中可以进行聚集的表进聚集:

1
CLUSTER;
support.huaweicloud.com/sqlreference-820-dws/dws_06_0153.html