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

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

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    
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄