场景:为了日常维护方便,同事将一大表全局索引都转为LOCAL本地索引,但由于主键不包含分区字段导致不能转成LOCAL属性;
测试验证如下:
SQL> create table pt
2 (
3 id number,
4 object_id number,
5 object_name varchar2(40)
6 )
7 partition by range(object_id)
8 (
9 partition T1 values less than (100) ,
10 partition T2 values less than (10000) ,
11 partition T3 values less than (maxvalue)
12 );
Table created.
SQL>
SQL>
SQL> create sequence seq01 start with 1 increment by 1 ;
Sequence created.
SQL> insert into pt select seq01.nextval ,object_id,object_name from dba_objects where object_id is not null;
75216 rows created.
SQL> commit;
Commit complete.
SQL> alter table pt add constraint pk_pt_id primary key(id) using index local;
alter table pt add constraint pk_pt_id primary key(id) using index local
*
ERROR at line 1:
ORA-14039: partitioning columns must form a subset of key columns of a UNIQUE
index
SQL> alter table pt add constraint pk_pt_id primary key(id,object_id) using index local;
Table altered.
SQL>
SQL> alter table pt drop primary key;
Table altered.
SQL> alter table pt add constraint pk_pt_object_id primary key(object_id) using index local;
Table altered.