首页 > 数据库 > Oracle > 非分区表=>分区表(三)
A>select * from a;
ID
----------
1
A>create table a_new as select * from a;
Table created.
--现在表A_NEW也有一条记录
A>select * from a_new;
ID
----------
1
如果此时向原表A中新插入一条记录,现在表T和T_NEW就不一致了
A>insert into a values(2);
1 row created.
A>select * from a_new;
ID
----------
1
A>select * from a;
ID
----------
1
2
A>commit;
Commit complete.
A>rename a to a_old;
Table renamed.
--在两个重命名操作中间,对原表A的访问会失败
A>select * from a;
select * from a
*
ERROR at line 1:
ORA-00942: table or view does not exist
A>rename a_new to a;
Table renamed.
A>select * from a;
ID
----------
1
综上,利用CTAS方式将堆表转换成分区表有两点要注意
1.尽量在闲时操作,以减少数据不一致情况的发生
2.在两个重命名操作中间,对原表的访问会失败
参考:http://edu.21cn.com/oracle/g_50_483124-1.htm
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29646619/viewspace-1165436/ ,如需转载,请注明出处,否则将追究法律责任。