ITPub博客

首页 > Linux操作系统 > Linux操作系统 > unique index unusable

unique index unusable

原创 Linux操作系统 作者:zhaohf_1106 时间:2010-01-18 15:22:50 0 删除 编辑

/*
 *如果是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博客 ” ,链接:https://blog.itpub.net/10173379/viewspace-625350/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-10-30

  • 博文量
    44
  • 访问量
    109394