Oracle不能並行直接添加主鍵的方法:先建唯一索引后建主鍵


環境: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 /* +parallel(8) +/  unique  index  pk_t  on  t(object_id) online;
Index  created
SQL>  alter  table  add  constraint  pk_t  primary  key  (object_id);
Table  altered
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM