Oracle 10gで「ORA-01502: index ‘xxx.xxxxx’ or partition of such index is in unusable state」エラーの対策

1.エラーメッセージ:
ORA-01502: index 'xxx.xxxxx’ or partition of such index is in unusable state

2.解決方法:
DBAでログイン、次のスクリプトを実行する
3.SQLコード
— DBA権限でログインし、スクリプトを実行
— 全てのUNUSABLEのindexを修復、rebuid
declare
— 全てのUNUSABLEステータスのindexカーソルを指す
cursor c is
select index_name, owner
from dba_indexes
where status=’UNUSABLE’;

owner dba_indexes.owner%type;
index_name dba_indexes.index_name%type;
begin
open c;
loop
fetch c into index_name, owner;
exit when c%notfound;

execute immediate 'alter index ' || owner || '.’ || index_name || ' rebuild’;
end loop;
close c;
end;

DataBase

Posted by arkgame