參考https://blog.csdn.net/hawksoft/article/details/52687421,
select index_name from user_indexes where status = 'UNUSABLE';
然後拿到index_name,重建失效索引
alter index 索引名稱 rebuild;
發現數據庫裏有90多條失效索引,如果一個一個拼的話,太多了
寫了個存儲過程,一次性重建所有失效索引
declare
vc_index_name varchar2(100); --索引名稱
cursor index_cur is
select index_name from user_indexes where status = 'UNUSABLE'; --獲取當前登錄用戶所有不可用的索引
begin
open index_cur;
fetch index_cur into vc_index_name;
loop
exit when not index_cur%found;
--dbms_output.put_line(vc_index_name);
execute immediate 'alter index '||vc_index_name||' rebuild';
fetch index_cur into vc_index_name;
end loop;
close index_cur;
end;