unique index unusable

本文探讨了在Oracle数据库中,当唯一性约束索引(PK)被设置为不可用状态后,对数据插入操作的影响。实验证明,即使使用skip_unusable参数,也无法向设置了不可用唯一性约束索引的表中插入数据,无论数据是否重复。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/*
 *如果是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/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值