Updated on 2024-05-20 GMT+08:00

Exchanging Level-2 Partitions for a Level-2 Partitioned Table

You can run ALTER TABLE EXCHANGE SUBPARTITION to exchange level-2 partitions in a level-2 partitioned table.

For example, exchange the level-2 partition date_202001_channel1 of the level-2 partitioned table range_list_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_list_sales EXCHANGE SUBPARTITION (date_202001_channel1) WITH TABLE exchange_sales WITHOUT VALIDATION UPDATE GLOBAL INDEX;
Alternatively, exchange the level-2 partition corresponding to ('2020-01-08', '0') in the level-2 partitioned table range_list_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_list_sales EXCHANGE SUBPARTITION FOR ('2020-01-08', '0') WITH TABLE exchange_sales WITH VALIDATION VERBOSE;

Partitions in a level-2 partitioned table cannot be exchanged.