Partition
Partitions in a partitioned table are tables that actually store data. The corresponding records are usually stored in pg_partition. Partitions are associated with the OID column of the partitioned table in the pg_class table through the parentid column. Example: t1_hash is a partitioned table.
gaussdb=# CREATE TABLE t1_hash (c1 INT, c2 INT, c3 INT)
PARTITION BY HASH(c1)
(
PARTITION p0,
PARTITION p1,
PARTITION p2,
PARTITION p3,
PARTITION p4,
PARTITION p5,
PARTITION p6,
PARTITION p7,
PARTITION p8,
PARTITION p9
);
-- Query the partitioning type of table t1_hash.
gaussdb=# SELECT oid, relname, parttype FROM pg_class WHERE relname = 't1_hash';
oid | relname | parttype
-------+---------+----------
16685 | t1_hash | p
(1 row)
-- Query the partition information about table t1_hash.
gaussdb=# SELECT oid, relname, parttype, parentid FROM pg_partition WHERE parentid = 16685;
oid | relname | parttype | parentid
-------+---------+----------+----------
16688 | t1_hash | r | 16685
16689 | p0 | p | 16685
16690 | p1 | p | 16685
16691 | p2 | p | 16685
16692 | p3 | p | 16685
16693 | p4 | p | 16685
16694 | p5 | p | 16685
16695 | p6 | p | 16685
16696 | p7 | p | 16685
16697 | p8 | p | 16685
16698 | p9 | p | 16685
(11 rows)
-- Drop table t1_hash.
gaussdb=# DROP TABLE t1_hash;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.