云和恩墨 成就所托 www.enmotech.com
1
第一章
变更前期准备
1.1
定位存在碎片的对象
使用如下脚本,检查需要进行碎片整理的对象:
--all tables(partition_tables + non_partition_tables )
set lines 200 pages 1000
col frag format 999999.99
col owner format a30;
col table_name format a30;
col frag for a20
select
a.owner,
a.table_name,
a.num_rows,
a.avg_row_len,
round(a.avg_row_len * a.num_rows/1024/1024,2) real_bytes_MB,
round(b.seg_bytes_mb,2) seg_bytes_mb ,
decode(a.num_rows,0,100,(1-round(a.avg_row_len *
a.num_rows/1024/1024/b.seg_bytes_mb,2))*100)||'%' frag_percent
from dba_tables a,
(select owner,segment_name,sum(bytes/1024/1024) seg_bytes_mb
from dba_segments group by owner,segment_name) b
where a.table_name=b.segment_name
and a.owner=b.owner
and a.owner not in
('SYS','SYSTEM','OUTLN','DMSYS','TSMSYS','DBSNMP','WMSYS',
'EXFSYS','CTXSYS','XDB','OLAPSYS','ORDSYS','MDSYS','SYSMAN')
and decode(a.num_rows,0,100,(1-round(a.avg_row_len *
a.num_rows/1024/1024/b.seg_bytes_mb,2))*100) >30
order by b.seg_bytes_mb desc;
文档被以下合辑收录
评论