ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 统计需要重建的索引

统计需要重建的索引

原创 Linux操作系统 作者:renjixinchina 时间:2012-12-07 16:10:05 0 删除 编辑
create or replace procedure sys.rebuildindex is
  tx varchar2(1000);
  /*create table index_rebuid (name varchar2(30),del_lf_rows number(12),lf_rows number(12),frag_pct varchar2(10));
  */
cursor cur is
select 'analyze index ' || a.owner || '.' || index_name ||
                   ' validate structure' as sql_text
              from dba_indexes a

             where a.table_name = 'TJFPERSONINFO';
begin
  for i in cur loop
    tx := i.sql_text;
    execute immediate tx;
    insert into index_rebuid
      (name, del_lf_rows, lf_rows, frag_pct)
      select name,
             del_lf_rows,
             lf_rows,
             round(del_lf_rows / decode(lf_rows, 0, 1, lf_rows) * 100, 0) || '%' frag_pct
        from index_stats
       where round(del_lf_rows / decode(lf_rows, 0, 1, lf_rows) * 100, 0) > 10;
  end loop;
  commit;
end;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15747463/viewspace-750759/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-01-30

  • 博文量
    373
  • 访问量
    2161066