分区交换的速度是非常快速的,只是数据字典的更新,在移动过程中,数据行的rowid都不会发生变化。实验过程如下:
1. 创建分区表
SQL> Create Table range_example(Id Number,Name Varchar2(20),DeptNO Varchar2(20))
2 Partition By List(DeptNO)
3 (
4 Partition p_mz Values('MZ'),
5 Partition p_zy Values('ZY')
6 )
7 ;
Table created
2.插入数据,表有两个分区
SQL> insert into range_example values
2 (1,'hxb','MZ');
1 row inserted
SQL> insert into range_example values
2 (1,'xzh','ZY');
1 row inserted
SQL> commit;
Commit complete
3.添加一个分区,以便做exhange操作
SQL> alter table range_example add partition p_qt values('QT');
Table altered
4.创建交换数据的表
SQL> create table emp(Id Number,Name Varchar2(20),DeptNO Varchar2(20))
2 ;
Table created
SQL> insert into emp values
2 (1,'phj','QT');
1 row inserted
SQL> commit;
Commit complete
5.查询rowid
SQL> select rowid from emp;
ROWID
------------------
AAASygAAHAACemwAAA
6.执行交换操作
SQL> alter table range_example
2 exchange partition p_qt
3 with table emp
4 without validation
5 ;
Table altered
7.分区交换后,发现rowid没有发生变化
SQL> select * from range_example partition(p_qt);
ID NAME DEPTNO
---------- -------------------- --------------------
1 phj QT
SQL> select rowid from range_example partition(p_qt);
ROWID
------------------
AAASygAAHAACemwAAA
SQL>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7839206/viewspace-1016393/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7839206/viewspace-1016393/