码迷,mamicode.com
首页 > 数据库 > 详细

oracle重建失效索引

时间:2016-02-04 18:17:58      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:

此脚本首先找到连接用户失效的索引,并在线重建.

create or replace procedure index_rebuild as
  cursor mycur is
    select *
      from user_indexes
     where status = ‘UNUSABLE‘;
  myrec user_indexes%rowtype;
  vsql  varchar(100);
begin
  open mycur;
  while mycur%found
  loop
    fetch mycur
      into myrec;
    dbms_output.put_line(‘index   ‘ || myrec.index_name || ‘  is invalide ‘);
    vsql := ‘alter index ‘ || myrec.index_name || ‘ rebuild online‘;
    dbms_output.put_line(vsql);
    execute immediate vsql;
  end loop;
  close mycur;
end index_rebuild;

oracle重建失效索引

标签:

原文地址:http://www.cnblogs.com/wangxingc/p/5181915.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!