環境:Oracle 11.2.0.3 需求:生產一張表由於前期設計不當,沒有主鍵。現需要添加主鍵,數據量很大,想並行建立。
1.直接添加,提示ora-3001:未實施的功能;只能單線程建立主鍵
SQL>
alter
table
t
add
constraint
pk_t
primary
key
(object_id) using
index
online parallel 2;
alter
table
t
add
constraint
pk_t
primary
key
(object_id) using
index
online parallel 2
ORA-03001: 未實施的功能
SQL>
alter
table
t
add
constraint
pk_t
primary
key
(object_id) using
index
online;
Table
altered
SQL>
alter
table
t
drop
primary
key
;
Table
altered
2.先開並發創建唯一索引,再改成主鍵
SQL>
create
/* +parallel(8) +/
unique
index
pk_t
on
t(object_id) online;
Index
created
SQL>
alter
table
t
add
constraint
pk_t
primary
key
(object_id);
Table
altered