Updated on 2024-06-07 GMT+08:00

Enabling/Disabling Automatic Level-1 List Partitioning

You can run ALTER TABLE SET PARTITIONING to enable or disable automatic level-1 list partitioning.

Examples:

  • Enable automatic partitioning of level-1 list partitioned tables.
    gaussdb=# CREATE TABLE list_int (c1 int, c2 int) 
    PARTITION BY LIST (c1)
    (
        PARTITION p1 VALUES (1, 2, 3),
        PARTITION p2 VALUES (4, 5, 6)
    );
    
    gaussdb=# ALTER TABLE list_int SET PARTITIONING AUTOMATIC;

    or

    gaussdb=# CREATE TABLE list_range (c1 int, c2 int)
    PARTITION BY LIST (c1) SUBPARTITION BY RANGE (c2)
    (
        PARTITION p1 VALUES (1, 2, 3) (
            SUBPARTITION sp11 VALUES LESS THAN (5),
            SUBPARTITION sp12 VALUES LESS THAN (10)
        ),
        PARTITION p2 VALUES (4, 5, 6) (
            SUBPARTITION sp21 VALUES LESS THAN (5),
            SUBPARTITION sp22 VALUES LESS THAN (10)
        )
    );
    
    gaussdb=# ALTER TABLE list_range SET PARTITIONING AUTOMATIC;

    To enable automatic level-1 list partitioning, ensure that no DEFAULT partition key exists in level-1 partitioned tables and level-1 partitions.

  • Disable automatic partitioning of level-1 list partitioned tables.
    gaussdb=# ALTER TABLE list_int SET PARTITIONING MANUAL;

    or

    gaussdb=# ALTER TABLE list_range SET PARTITIONING MANUAL;

    Cleanup example:

    gaussdb=# DROP TABLE list_int;
    gaussdb=# DROP TABLE list_range;