数据库异常处理
1. ora-01502数据库索引失效
(1) 数据库索引失效原因:
原因:
1. 出现这个问题,可能有人move过表,或者disable 过索引。
alter table xxxxxx move tablespace xxxxxxx 命令后,索引就会失效。
alter index index_name unusable,命令使索引失效。
2. 也有可能是表空间数据文件追加,或者表空间数据文件扩容出现跨物理磁盘。
(2) 解决方法:
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. 改变当前索引的名字。
(3) 查询数据库失效的对象
1、检查无效的数据库对象:
SELECT owner, object_name, object_type,status
FROM dba_objects
WHERE status = 'INVALID';
2、检查不起作用的约束:
SELECT owner, constraint_name, table_name, constraint_type, status
FROM dba_constraints
WHERE status = 'DISABLED';
3、检查无效的触发器:
SELECT owner, trigger_name, table_name, status
FROM dba_triggers
WHERE status = 'DISABLED';
4、检查失效的索引:
select owner, index_name,table_name,tablespace_name,status
From dba_indexes
Where status<>'VALID';