ITPub博客

首页 > IT职业 > IT生活 > [ADMIN]A misunderstanding

[ADMIN]A misunderstanding

原创 IT生活 作者:chenyan995 时间:2009-04-14 14:18:00 0 删除 编辑

I used to consider that an unusable index may cause DML changes fail. In fact, only the index related to a constraint may lead to such situation.

SQL> create table move_test(cola number);

表已创建。

SQL> begin
2 for i in 1..10 loop
3 insert into move_test values(i);
4 end loop;
5 commit;
6 end;
7 /

PL/SQL 过程已成功完成。

SQL> select * rom move_test;
select * rom move_test
*
第 1 行出现错误:
ORA-00923: 未找到要求的 FROM 关键字


SQL> select * from move_test;

COLA
----------
1
2
3
4
5
6
7
8
9
10

已选择10行。

SQL> create index idx1_move_test on move_test(cola);

索引已创建。

SQL> insert into move_test values(11);

已创建 1 行。

SQL> commit;

提交完成。

SQL> alter table move_test move;

表已更改。

SQL> select status from user_indexes where index_name='IDX1_MOVE_TEST';

STATUS
--------
UNUSABLE

SQL> insert into move_test values(12);

已创建 1 行。

SQL> commit;

提交完成。

SQL> select status from user_indexes where index_name='IDX1_MOVE_TEST';

STATUS
--------
UNUSABLE

SQL> alter index idx1_move_test rebuild;

索引已更改。

SQL> alter table move_test add primary key(cola);

表已更改。

SQL> select index_name from user_indexes where table_name='MOVE_TEST';

INDEX_NAME
------------------------------
IDX1_MOVE_TEST

SQL> alter table move_test move;

表已更改。

SQL> select status from user_indexes where index_name='IDX1_MOVE_TEST';

STATUS
--------
UNUSABLE

SQL> insert into move_test values(13);
insert into move_test values(13)
*
第 1 行出现错误:
ORA-01502: 索引 'YCHEN.IDX1_MOVE_TEST' 或这类索引的分区处于不可用状态


SQL> alter index idx1_move_test rebuild;

索引已更改。

SQL> insert into move_test values(13);

已创建 1 行。

SQL> commit;

提交完成。

[@more@]A

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8558093/viewspace-1020495/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    34
  • 访问量
    73625