首页 > 数据库技术 > 详细

Oracle并行添加主键的方法

时间:2019-04-14 17:06:06      阅读:295      评论:0      收藏:0      [点我收藏+]

环境:Oracle 11.2.0.3 需求:生产一张表由于前期设计不当,没有主键。现需要添加主键,数据量很大,想并行建立。

 

1.直接添加,提示ora-3001:未实施的功能;只能单线程建立主键

SQL> alter table add constraint pk_t primary key (object_id) using index online parallel 2;

 
alter table add constraint pk_t primary key (object_id) using index online parallel 2
 
ORA-03001: 未实施的功能
 
SQL> alter table add constraint pk_t primary key (object_id) using index online;
 
Table altered
 
SQL> alter table drop primary key;
 
Table altered
 
2.考虑先并行添加惟一性索引,再添加主键
SQL> create unique index pk_t on t(object_id) parallel 2 online;
 
Index created
 
SQL> alter table add constraint pk_t primary key (object_id);
 
Table altered
 
SQL> alter index pk_t noparallel;
 
Index altered
 
 

Oracle并行添加主键的方法

原文:https://www.cnblogs.com/zjpeng/p/10705729.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!