近期,一金融客户的核心系统进行索引维护,在创建分区索引时,使用了不可见、不可用状态,但是创建完成后导致INSERT语句操作失败;经过试验分区索引去除UNUSABLE时,INSERT等DML操作不受影响。
试验验证如下:
1、创建模拟的分区表
SQL> CREATE TABLE T_NEW (ID int, TIME date,name varchar2(20)) PARTITION BY RANGE (TIME)
(PARTITION P1 VALUES LESS THAN (TO_DATE('2018-1-1', 'YYYY-MM-DD')),
PARTITION P2 VALUES LESS THAN (TO_DATE('2018-2-1', 'YYYY-MM-DD')),
PARTITION P3 VALUES LESS THAN (TO_DATE('2018-3-1', 'YYYY-MM-DD')),
PARTITION P4 VALUES LESS THAN (MAXVALUE)); 2 3 4 5
Table created.
SQL>
2、插入数据测试分区表可用
SQL> insert into t_new values(1,TO_DATE('2018-1-15', 'YYYY-MM-DD'),'hellow');
1 row created.
SQL>
SQL> commit;
Commit complete.
SQL> select * from t_new;
ID TIME NAME
---------- --------- --------------------
1 15-JAN-18 hellow
SQL>
3、创建业务变更的不可见不可用分区索引
SQL> create unique index IDX1 on t_new (id, time) local invisible nologging unusable;
Index created.
SQL>
4、执行INSERT插入失败,提示:ORA-01502分区索引状态为不可用
SQL> insert into t_new values(1,TO_DATE('2018-3-15', 'YYYY-MM-DD'),'yellow');
insert into t_new values(1,TO_DATE('2018-3-15', 'YYYY-MM-DD'),'yellow')
*
ERROR at line 1:
ORA-01502: index 'TEST.IDX1' or partition of such index is in unusable state
SQL>
5、重新创建索引去掉UNUSABLE关键字
SQL> drop index idx1;
Index dropped.
SQL> create unique index IDX1 on t_new (id, time) local invisible nologging ;
Index created.
SQL>
6、模拟INSERT插入不受影响
SQL> insert into t_new values(1,TO_DATE('2018-3-15', 'YYYY-MM-DD'),'yellow');
1 row created.
SQL>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29357786/viewspace-2212709/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29357786/viewspace-2212709/