shrink 实例

create table t nologging
as
select o.* from
(select * from dba_objects where rownum <10001) o,
(select * from dba_objects where rownum <101) o2
order by o.object_id;
 
select bytes/1024/1024 from user_segments where segment_name='T';
T大小为104M
 
select count(*) from t;
 
delete from t where mod(object_id,2)=0;
 
commit;
 
select count(*) from t;
 
alter table t enable row movement;
 
select a.name,b.value
from v$statname a,v$mystat b
where a.statistic#=b.statistic# and a.name='redo size';
shrink之前redo size 173M
 
alter table t shrink space;
 
select a.name,b.value
from v$statname a,v$mystat b
where a.statistic#=b.statistic# and a.name='redo size';
shrink之后 redo size 356M
 
select bytes/1024/1024 from user_segments where segment_name='T';
46M
 
分析table
 analyze table TBLMINNO compute statistics;
 
select table_name,num_rows,AVG_ROW_LEN,BLOCKS,EMPTY_BLOCKS from dba_tables
where table_name='TBLMINNO';

你可能感兴趣的:(oracle,职场,休闲)