oracle重建失效索引
此脚本首先找到连接用户失效的索引,并在线重建.
1 create or replace procedure index_rebuild as 2 cursor mycur is 3 select * 4 from user_indexes 5 where status = 'UNUSABLE'; 6 myrec user_indexes%rowtype; 7 vsql varchar(100); 8 begin 9 open mycur; 10 while mycur%found 11 loop 12 fetch mycur 13 into myrec; 14 dbms_output.put_line('index ' || myrec.index_name || ' is invalide '); 15 vsql := 'alter index ' || myrec.index_name || ' rebuild online'; 16 dbms_output.put_line(vsql); 17 execute immediate vsql; 18 end loop; 19 close mycur; 20 end index_rebuild;
posted on 2016-02-04 16:46 wangxingc 阅读(1755) 评论(0) 编辑 收藏 举报