压缩表记录大小

    1,查询各用户名下用户的记录

    select t.OWNER || '.' ||t.table_name names,t.num_rows from dba_tables t where t.OWNER in ('ORD','PROD','TICKET','MEM','ADMINCAS','MIDDLE','CHART') AND t.NUM_ROWS is not null order by t.num_rows desc;

     

    2,压缩,不要忘记要重建索引

    ALTER TABLE  owner.tableName MOVE ; 

     

     

    3,统计分析表

    analyze table  owner.tableName compute statistics;

     

    如果提示object statistics are locked 

    先使用如下命令解锁

    exec dbms_stats.unlock_table_stats('OWNER','tableName');

    或者

    begin

    dbms_stats.unlock_table_stats('OWNER','tableName');
    end;

    然后执行  analyze table  owner.tableName compute statistics;

    4,查询索引是否需要重建

    select 'alter index '||owner||'.'||index_name ||' rebuild online ; ' command,table_name,tablespace_name,index_type,status from dba_indexes where table_name ='tableName';

    5,重建索引

    alter index OWNER.INDEXNAME rebuild online

     

    6,效果检验 -- 水位线查询


    select TABLE_NAME,TABLESPACE_NAME,BLOCKS,EMPTY_BLOCKS from DBA_tables where table_name='T_QUERY_ORDERCOUNT';

    联系QQ:343886028 --加QQ群 145315854