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

时间:2024-10-21 16:50:40

示例

重建一个单独索引:

1
REINDEX INDEX tpcds.tpcds_customer_index1;

重建表tpcds.customer_t1上的所有索引:

1
REINDEX TABLE tpcds.customer_t1;

重建分区表customer_address分区P1的分区索引:

DROP TABLE IF EXISTS customer_address;
CREATE TABLE customer_address
(
    ca_address_sk       INTEGER                  NOT NULL   ,
    ca_address_id       CHARACTER(16)            NOT NULL   ,
    ca_street_number    CHARACTER(10)                       ,
    ca_street_name      CHARACTER varying(60)               ,
    ca_street_type      CHARACTER(15)                       ,
    ca_suite_number     CHARACTER(10)                    
)
DISTRIBUTE BY HASH (ca_address_sk)
PARTITION BY RANGE(ca_address_sk)
(
        PARTITION P1 VALUES LESS THAN(2450815),
        PARTITION P2 VALUES LESS THAN(2451179),
        PARTITION P3 VALUES LESS THAN(2451544),
        PARTITION P4 VALUES LESS THAN(MAXVALUE)
);

CREATE INDEX customer_address_index on customer_address(CA_ADDRESS_SK) LOCAL;

REINDEX TABLE customer_address PARTITION P1;
support.huaweicloud.com/sqlreference-830-dws/dws_06_0218.html