/*
*如果是PK的unique index设置为unusable之后将不能向其中插入数据,这样在imp 时使用skip_unusable参数也不起作用,不管数据重复与否都无法
插入表。
*/
SQL> create table test(id int, name varchar2(32));
Table created.
SQL> alter table test add constraint pk_test_id primary key (id);
Table altered.
SQL> insert into test values(1, 'a');
1 row created.
SQL> insert into test values(2, 'b');
1 row created.
SQL> commit;
Commit complete.
SQL> select index_name from user_indexes where table_name = 'TEST';
INDEX_NAME
------------------------------
PK_TEST_ID
SQL> alter index pk_test_id unusable;
Index altered.
SQL> select index_name, status from user_indexes where table_name = 'TEST';
INDEX_NAME STATUS
------------------------------ --------
PK_TEST_ID UNUSABLE
SQL> SELECT * from test;
ID NAME
---------- --------------------------------
1 a
2 b
3 c
4 d
5 e
SQL> insert into test values(5, 'e');
insert into test values(5, 'e')
*
ERROR at line 1:
ORA-01502: index 'ZHF.PK_TEST_ID' or partition of such index is in unusable
state
SQL>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10173379/viewspace-625350/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10173379/viewspace-625350/
本文探讨了在Oracle数据库中,当唯一性约束索引(PK)被设置为不可用状态后,对数据插入操作的影响。实验证明,即使使用skip_unusable参数,也无法向设置了不可用唯一性约束索引的表中插入数据,无论数据是否重复。
511

被折叠的 条评论
为什么被折叠?



