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

Exchanging Partitions for a Partitioned Table

You can run ALTER TABLE EXCHANGE PARTITION to exchange partitions for a partitioned table.

For example, exchange the partition date_202001 of the partitioned table range_sales with the ordinary table exchange_sales by specifying the partition name without validating the partition key, and update the global index.
ALTER TABLE range_sales EXCHANGE PARTITION (date_202001) WITH TABLE exchange_sales WITHOUT VALIDATION UPDATE GLOBAL INDEX;
Alternatively, exchange the partition corresponding to '2020-01-08' in the range partitioned table range_sales with the ordinary table exchange_sales by specifying a partition value, validate the partition, and insert data that does not meet the target partition constraints into another partition of the partitioned table. Global indexes become invalid after this command is executed because the UPDATE GLOBAL INDEX clause is not used.
ALTER TABLE range_sales EXCHANGE PARTITION FOR ('2020-01-08') WITH TABLE exchange_sales WITH VALIDATION VERBOSE;