暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

ORACLE 索引的三种状态: VALID、 N/A 、UNUSABLE

原创 天空 2023-11-21
3172

ORACLE 索引的三种状态:

    valid:当前索引有效
    N/A :分区索引有效
    unusable:索引失效

Oracle异常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';

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论