温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Oracle无效索引修复

发布时间:2020-08-13 04:27:39 来源:ITPUB博客 阅读:429 作者:数据小魏 栏目:关系型数据库

ORA-01502: 索引或这类索引的分区处于不可用状态

原因: 出现这个问题,可能有人move过表,或者disable 过索引。
1. alter table xxxxxx move tablespace xxxxxxx 命令后,索引就会失效。
2. alter index index_name  unusable,命令使索引失效。

解决办法:
1. 重建索引才是解决这类问题的完全的方法。
     alter index index_name rebuild (online);

     或者alter index index_name rebuild;
2. 如果是分区索引只需要重建那个失效的分区 。
     alter index index_name rebuild partition partition_name (online);

     或者alter index index_name rebuild partition partition_name ;

3. 或者改变当前索引的名字。

说明:
1. alter session set skip_unusable_indexes=true;就可以在session级别跳过无效索引作查询。
2. 分区索引应适用user_ind_partitions。
3. 状态分4种:
    N/A说明这个是分区索引需要查user_ind_partitions或者user_ind_subpartitions来确定每个分区是否可用;
    VAILD说明这个索引可用;
    UNUSABLE说明这个索引不可用;
    USABLE 说明这个索引的分区是可用的。

4. 查询当前索引的状态:select distinct status from user_indexes;

5. 查询那个索引无效:select index_name from  user_indexes where status <> 'VALID';

6. 详细讲解可参考:http://www.sudu.cn/info/html/edu/20071225/20526.html。

7. 批量rebuild下:select 'alter index '||index_name||' rebuild online;' from  user_indexes where status <> 'VALID' and index_name not like'%$$';


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI