zoukankan      html  css  js  c++  java
  • MoveTable and Reindex

    --collect index info
    create table idx_stats
    as select * from index_stats where 1=2

    begin
     for mycur in (select index_name from user_indexes) loop
      execute immediate 'analyze index '|| mycur.index_name ||
      ' validate structure';
        insert into idx_stats select * from index_stats;
      commit;
     end loop;
    end;

    --move table
    SET SERVEROUTPUT ON ;
    begin
     for mycur in (select table_name from user_tables  where TABLESPACE_NAME='TS_GES_01' AND table_name!='TOAD_PLAN_TABLE') loop
        dbms_output.put_line('move table:'|| mycur.table_name);
      execute immediate 'alter table '|| mycur.table_name ||' move';
     end loop;
    end;

    --rebulid index
    select 'alter index ' ||name || ' rebuild online;'
    from idx_stats
    where DEL_LF_rows/nullif(LF_Rows,0)>=0


    --check table
    select name,table_space from dba_tables where owner='POLY'

    --check index
    select index_name,status from user_indexes

    --load new index stat
    create table idx_stats2

    as select * from index_stats where 1=2
    begin
     for mycur in (select index_name from user_indexes) loop
      execute immediate 'analyze index '|| mycur.index_name ||
      ' validate structure';
        insert into idx_stats2 select * from index_stats;
      commit;
     end loop;
    end;
    --compare index stat
    select * from poly.idx_stats --142
    WHERE DEL_LF_rows/nullif(LF_Rows,0)>=0 --115
    order by DEL_LF_rows desc

    select * from poly.idx_stats2 --142
    WHERE DEL_LF_rows/nullif(LF_Rows,0)>=0 --115
    order by DEL_LF_rows

    select a.name, a.DEL_LF_rows/nullif(a.LF_Rows,0) as ratio_a,
     b.DEL_LF_rows/nullif(b.LF_Rows,0) as ratio_b
    from poly.idx_stats a
    inner join  poly.idx_stats2 b on a.name=b.name
    order by 2 desc

    --recompile package
    SELECT
     'alter '||decode(object_type,'PACKAGE BODY','PACKAGE',object_type) ||' '||owner||
      '."'||object_name||'" '||decode(object_type,'PACKAGE BODY','COMPILE BODY','COMPILE')||';'
     FROM all_objects
     WHERE owner like '%'
     AND owner not in ('SYS', 'SYSTEM')
     AND object_type IN
     ('PACKAGE','PACKAGE BODY','VIEW','PROCEDURE','TRIGGER','FUNCTION')
     AND status='INVALID';

  • 相关阅读:
    java.net.BindException: Cannot assign requested address: bind
    Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'name': was expecting ('true', 'false' or 'null')
    springMVC上传错误StandardMultipartHttpServletRequest
    常用软件
    虚拟机修改静态ip
    linux下脚本做成服务
    Unable to resolve persistence unit root URL
    MyBatis对不同数据库的主键生成策略
    MyBatis定义复合主键
    MongoDB安装,启动,注册为windows系统服务
  • 原文地址:https://www.cnblogs.com/weaver1/p/2440959.html
Copyright © 2011-2022 走看看