Oracle Partition Table exchange principle oracle partition exchange operation is very fast, then what is the principle? Let's create an experiment:
SQL> create table test (id number (3); the table has been created. SQL> insert into test values (1); 1 row has been created. SQL> commit; submitted completely. SQL> select object_id, data_object_id from user_objects s where s. object_name = 'test'; OBJECT_ID DATA_OBJECT_ID ---------- -------------- 180148 180148SQL> create table test_part (id number (3) partition by range (id) 2 (partition p1 values less than (10 ), 3 partition p2 values less than (20); the table has been created. SQL> col object_name format a20SQL> col subobject_name format a20SQL> select object_name, s. subobject_name, object_id, data_object_id 2 from user_objects s 3 where s. object_name = 'test _ part'; OBJECT_NAME SUBOBJECT_NAME OBJECT_ID DATA_OBJECT_ID contains bytes ---------- -------------- TEST_PART P1 180150 180150TEST_PART P2 180151 180151TEST_PART 180149SQL> select * from TEST; ID ---------- 1SQL> select * from test_part; unselected row SQL> alter table test_part exchange partition p1 with table test; the table has been changed. SQL> select * from test; select * from test_part; ID ---------- 1SQL> select * from test_part partition (p1); ID ---------- 1SQL> select object_id, data_object_id from user_objects s where s. object_name = 'test'; OBJECT_ID DATA_OBJECT_ID ---------- -------------- 180148 180150SQL> select object_name, s. subobject_name, object_id, data_object_id 2 from user_objects s 3 where s. object_name = 'test _ part'; OBJECT_NAME SUBOBJECT_NAME OBJECT_ID DATA_OBJECT_ID -------------------- ------------------ -------------- TEST_PART P1 180150 180148TEST_PART P2 180151 180151TEST_PART 180149
Exchange only modifies the partition and table structure in the oracle Data dictionary. Data has not been modified, so the speed is fast. In more detail, we only exchanged the data_object_id corresponding to different object_ids, but the segment itself has not changed and has nothing to do with the physical storage location. However, it must be between a partition table and a non-partition table.