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

MERGE PARTITION

You can run this command to merge multiple partitions into one partition. Partitions can be merged only by specifying partition names, instead of partition values.

  • This command cannot be applied to hash partitions.
  • Running this command will invalidate the global index. You can use the UPDATE GLOBAL INDEX clause to update the global index synchronously or rebuild the global index.
  • If any partition before combination contains a sparsely partitioned index, the partition cannot be combined.

For a range partition, the name of the new partition can be the same as that of the last source partition. For example, partitions p1 and p2 can be merged into p2. For a list partition, the name of the new partition can be the same as that of any source partition. For example, p1 and p2 can be merged into p1.

If the name of the new partition is the same as that of the source partition, the database considers the new partition as inheritance of the source partition.

You can use ALTER TABLE MERGE PARTITIONS to merge multiple partitions into one partition.

For example, merge the partitions date_202001 and date_202002 of the range partitioned table range_sales into a new partition and update the global index.
ALTER TABLE range_sales MERGE PARTITIONS date_202001, date_202002 INTO
    PARTITION date_2020_old UPDATE GLOBAL INDEX;