Help Center/ GaussDB/ Distributed_3.x/ Partitioned Table/ Partitioned Table O&M Management/ SPLIT PARTITION/ Splitting a Partition for a Range Partitioned Table
Updated on 2024-05-20 GMT+08:00

Splitting a Partition for a Range Partitioned Table

You can run ALTER TABLE SPLIT PARTITION to split a partition for a range partitioned table.

For example, the range of the date_202001 partition in the range partitioned table range_sales is ['2020-01-01', '2020-02-01'). You can specify the split point '2020-01-16' to split the date_202001 partition into two partitions and update the global index.
ALTER TABLE range_sales SPLIT PARTITION date_202001 AT ('2020-01-16') INTO
(
    PARTITION date_202001_p1, -- The upper boundary of the first partition is '2020-01-16'.
    PARTITION date_202001_p2  -- The upper boundary of the second partition is '2020-02-01'.
) UPDATE GLOBAL INDEX;
Alternatively, split the partition date_202001 into multiple partitions without specifying a split point, and update the global index.
ALTER TABLE range_sales SPLIT PARTITION date_202001 INTO
(
    PARTITION date_202001_p1 VALUES LESS THAN ('2020-01-11'),
    PARTITION date_202001_p2 VALUES LESS THAN ('2020-01-21'),
    PARTITION date_202001_p3 -- The upper boundary of the third partition is '2020-02-01'.
)UPDATE GLOBAL INDEX;
Alternatively, split the partition by specifying the partition value instead of the partition name.
ALTER TABLE range_sales SPLIT PARTITION FOR ('2020-01-15') AT ('2020-01-16') INTO
(
    PARTITION date_202001_p1, -- The upper boundary of the first partition is '2020-01-16'.
    PARTITION date_202001_p2  -- The upper boundary of the second partition is '2020-02-01'.
) UPDATE GLOBAL INDEX;

If the MAXVALUE partition is split, the MAXVALUE range cannot be declared for the first several partitions, and the last partition inherits the MAXVALUE range.