数据仓库服务 GAUSSDB(DWS)-DBA_TAB_PARTITIONS:应用示例

时间:2024-06-29 17:51:20

应用示例

查看分区表的分区信息:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
CREATE TABLE web_returns_p1
(
    wr_returned_date_sk       integer,
    wr_returned_time_sk       integer,
    wr_item_sk                integer NOT NULL,
    wr_refunded_customer_sk   integer
)
WITH (orientation = column)
DISTRIBUTE BY HASH (wr_item_sk)
PARTITION BY RANGE (wr_returned_date_sk)
(
    PARTITION p2016 VALUES LESS THAN(20161231),
    PARTITION p2017 VALUES LESS THAN(20171231),
    PARTITION p2018 VALUES LESS THAN(20181231),
    PARTITION p2019 VALUES LESS THAN(20191231),
    PARTITION p2020 VALUES LESS THAN(maxvalue)
);

SELECT * FROM dba_tab_partitions where table_name='web_returns_p1';
 table_owner | schema |   table_name   | partition_name | high_value | pretty_high_value |  tablespace_name
-------------+--------+----------------+----------------+------------+-------------------+--------------------
 dbadmin     | public | web_returns_p1 | p2016          | 20161231   | 20161231          | DEFAULT TABLESPACE
 dbadmin     | public | web_returns_p1 | p2017          | 20171231   | 20171231          | DEFAULT TABLESPACE
 dbadmin     | public | web_returns_p1 | p2018          | 20181231   | 20181231          | DEFAULT TABLESPACE
 dbadmin     | public | web_returns_p1 | p2019          | 20191231   | 20191231          | DEFAULT TABLESPACE
 dbadmin     | public | web_returns_p1 | p2020          | MAXVALUE   | MAXVALUE          | DEFAULT TABLESPACE
(5 rows)
support.huaweicloud.com/devg-830-dws/dws_04_0676.html