Subpartitioning
- Range-range
- Range-list
- Range-hash
- List-range
- List-list
- List-hash
- Hash-range
- Hash-list
- Hash-hash
Example:
-- Range-range gaussdb=# CREATE TABLE t_range_range ( c1 INT, c2 INT, c3 INT ) PARTITION BY RANGE (c1) SUBPARTITION BY RANGE (c2) ( PARTITION p1 VALUES LESS THAN (10) ( SUBPARTITION p1sp1 VALUES LESS THAN (5), SUBPARTITION p1sp2 VALUES LESS THAN (10) ), PARTITION p2 VALUES LESS THAN (20) ( SUBPARTITION p2sp1 VALUES LESS THAN (15), SUBPARTITION p2sp2 VALUES LESS THAN (20) ) ); gaussdb=# DROP TABLE t_range_range; -- Range-list gaussdb=# CREATE TABLE t_range_list ( c1 INT, c2 INT, c3 INT ) PARTITION BY RANGE (c1) SUBPARTITION BY LIST (c2) ( PARTITION p1 VALUES LESS THAN (10) ( SUBPARTITION p1sp1 VALUES (1, 2), SUBPARTITION p1sp2 VALUES (3, 4) ), PARTITION p2 VALUES LESS THAN (20) ( SUBPARTITION p2sp1 VALUES (1, 2), SUBPARTITION p2sp2 VALUES (3, 4) ) ); gaussdb=# DROP TABLE t_range_list; -- Range-hash gaussdb=# CREATE TABLE t_range_hash ( c1 INT, c2 INT, c3 INT ) PARTITION BY RANGE (c1) SUBPARTITION BY HASH (c2) SUBPARTITIONS 2 ( PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (20) ); gaussdb=# DROP TABLE t_range_hash; -- List-range gaussdb=# CREATE TABLE t_list_range ( c1 INT, c2 INT, c3 INT ) PARTITION BY LIST (c1) SUBPARTITION BY RANGE (c2) ( PARTITION p1 VALUES (1, 2) ( SUBPARTITION p1sp1 VALUES LESS THAN (5), SUBPARTITION p1sp2 VALUES LESS THAN (10) ), PARTITION p2 VALUES (3, 4) ( SUBPARTITION p2sp1 VALUES LESS THAN (5), SUBPARTITION p2sp2 VALUES LESS THAN (10) ) ); gaussdb=# DROP TABLE t_list_range; -- List-list gaussdb=# CREATE TABLE t_list_list ( c1 INT, c2 INT, c3 INT ) PARTITION BY LIST (c1) SUBPARTITION BY LIST (c2) ( PARTITION p1 VALUES (1, 2) ( SUBPARTITION p1sp1 VALUES (1, 2), SUBPARTITION p1sp2 VALUES (3, 4) ), PARTITION p2 VALUES (3, 4) ( SUBPARTITION p2sp1 VALUES (1, 2), SUBPARTITION p2sp2 VALUES (3, 4) ) ); gaussdb=# DROP TABLE t_list_list; -- List-hash gaussdb=# CREATE TABLE t_list_hash ( c1 INT, c2 INT, c3 INT ) PARTITION BY LIST (c1) SUBPARTITION BY HASH (c2) SUBPARTITIONS 2 ( PARTITION p1 VALUES (1, 2), PARTITION p2 VALUES (3, 4) ); gaussdb=# DROP TABLE t_list_hash; -- Hash-range gaussdb=# CREATE TABLE t_hash_range ( c1 INT, c2 INT, c3 INT ) PARTITION BY HASH (c1) PARTITIONS 2 SUBPARTITION BY RANGE (c2) ( PARTITION p1 ( SUBPARTITION p1sp1 VALUES LESS THAN (5), SUBPARTITION p1sp2 VALUES LESS THAN (10) ), PARTITION p2 ( SUBPARTITION p2sp1 VALUES LESS THAN (5), SUBPARTITION p2sp2 VALUES LESS THAN (10) ) ); gaussdb=# DROP TABLE t_hash_range; -- Hash-list gaussdb=# CREATE TABLE t_hash_list ( c1 INT, c2 INT, c3 INT ) PARTITION BY HASH (c1) PARTITIONS 2 SUBPARTITION BY LIST (c2) ( PARTITION p1 ( SUBPARTITION p1sp1 VALUES (1, 2), SUBPARTITION p1sp2 VALUES (3, 4) ), PARTITION p2 ( SUBPARTITION p2sp1 VALUES (1, 2), SUBPARTITION p2sp2 VALUES (3, 4) ) ); gaussdb=# DROP TABLE t_hash_list; -- Hash-hash gaussdb=# CREATE TABLE t_hash_hash ( c1 INT, c2 INT, c3 INT ) PARTITION BY HASH (c1) PARTITIONS 2 SUBPARTITION BY HASH (c2) SUBPARTITIONS 2 ( PARTITION p1, PARTITION p2 ); gaussdb=# DROP TABLE t_hash_hash;
Interval partitioning is a special form of range partitioning. Currently, interval partitioning cannot be defined in subpartitioning.
The partitions and level-2 partitions of a level-2 partitioned table support a one-column partition key only.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot