- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
4#
发表于 2013-2-20 09:48:00
- ttitle -
- center 'Database Freespace Summary' skip 2
-
- comp sum of nfrags totsiz avasiz on report
- break on report
- set pages 999
- col tsname format a16 justify c heading 'Tablespace'
- col nfrags format 999,990 justify c heading 'Free|Frags'
- col mxfrag format 999,999 justify c heading 'Largest|Frag (MB)'
- col totsiz format 999,999 justify c heading 'Total|(MB)'
- col avasiz format 999,999 justify c heading 'Available|(MB)'
- col pctusd format 990 justify c heading 'Pct|Used'
- select total.TABLESPACE_NAME tsname,
- D nfrags,
- C/1024/1024 mxfrag,
- A/1024/1024 totsiz,
- B/1024/1024 avasiz,
- (1-nvl(B,0)/A)*100 pctusd
- from
- (select sum(bytes) A,
- tablespace_name
- from dba_data_files
- group by tablespace_name) TOTAL,
- (select sum(bytes) B,
- max(bytes) C,
- count(bytes) D,
- tablespace_name
- from dba_free_space
- group by tablespace_name) FREE
- where
- total.TABLESPACE_NAME=free.TABLESPACE_NAME(+)
- /
- SELECT t.tablespace_name,
- CASE
- WHEN t.contents = 'TEMPORARY' AND t.extent_management = 'LOCAL' THEN
- u.bytes
- ELSE
- df.user_bytes - NVL(fs.bytes, 0)
- END / 1024 / 1024 used_mb,
- CASE
- WHEN t.contents = 'TEMPORARY' AND t.extent_management = 'LOCAL' THEN
- df.user_bytes - NVL(u.bytes, 0)
- ELSE
- NVL(fs.bytes, 0)
- END / 1024 / 1024 free_mb,
- fs.min_fragment / 1024 / 1024 min_fragment_mb,
- fs.max_fragment / 1024 / 1024 max_fragment_mb,
- (fs.bytes / 1024 / 1024) / fs.fragments avg_fragment_mb,
- fs.fragments,
- t.status,
- t.contents,
- t.logging,
- t.extent_management,
- t.allocation_type,
- t.force_logging,
- t.segment_space_management,
- t.def_tab_compression,
- t.retention,
- t.bigfile
- FROM dba_tablespaces t,
- (SELECT tablespace_name,
- SUM(bytes) bytes,
- MIN(min_fragment) min_fragment,
- MAX(max_fragment) max_fragment,
- SUM(fragments) fragments
- FROM (SELECT tablespace_name,
- SUM(bytes) bytes,
- MIN(bytes) min_fragment,
- MAX(bytes) max_fragment,
- COUNT(*) fragments
- FROM dba_free_space
- GROUP BY tablespace_name
- UNION ALL
- SELECT tablespace_name,
- SUM(bytes) bytes,
- MIN(bytes) min_fragment,
- MAX(bytes) max_fragment,
- COUNT(*) fragments
- FROM dba_undo_extents
- WHERE status = 'EXPIRED'
- GROUP BY tablespace_name)
- GROUP BY tablespace_name) fs,
- (SELECT tablespace_name, SUM(user_bytes) user_bytes
- FROM dba_data_files
- GROUP BY tablespace_name
- UNION ALL
- SELECT tablespace_name, SUM(user_bytes) user_bytes
- FROM dba_temp_files
- GROUP BY tablespace_name) df,
- (SELECT tablespace_name, SUM(bytes_used) bytes
- FROM gv$temp_extent_pool
- GROUP BY tablespace_name) u
- WHERE t.tablespace_name = df.tablespace_name(+)
- AND t.tablespace_name = fs.tablespace_name(+)
- AND t.tablespace_name = u.tablespace_name(+)
- /
- select count(distinct segment_name) from dba_extents where tablespace_name='DATA_0000';
- select blocks,count(*) from dba_extents where tablespace_name='DATA_0000' group by blocks;
复制代码 查一下 结果保存成txt 不要截图 |
|