码迷,mamicode.com
首页 > 数据库 > 详细

oracle 11g 表空间使用率

时间:2016-02-01 14:32:18      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:

Oracle数据库表空间使用量查询:

 

select b.file_name 物理文件名,
b.tablespace_name 表空间,
b.bytes/1024/1024 大小M,
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024 已使用M,
substr((b.bytes-sum(nvl(a.bytes,0)))/(b.bytes)*100,1,5) 利用率
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,b.file_name,b.bytes
order by b.tablespace_name;

 

-------------------------------------------------------------

 

SELECT D.TABLESPACE_NAME, 
SPACE || ‘M‘ "SUM_SPACE(M)", 
BLOCKS "SUM_BLOCKS", 
SPACE - NVL (FREE_SPACE, 0) || ‘M‘ "USED_SPACE(M)", 
ROUND ( (1 - NVL (FREE_SPACE, 0) / SPACE) * 100, 2) || ‘%‘ 
"USED_RATE(%)", 
FREE_SPACE || ‘M‘ "FREE_SPACE(M)" 
FROM ( SELECT TABLESPACE_NAME, 
ROUND (SUM (BYTES) / (1024 * 1024), 2) SPACE, 
SUM (BLOCKS) BLOCKS 
FROM DBA_DATA_FILES 
GROUP BY TABLESPACE_NAME) D, 
( SELECT TABLESPACE_NAME, 
ROUND (SUM (BYTES) / (1024 * 1024), 2) FREE_SPACE 
FROM DBA_FREE_SPACE 
GROUP BY TABLESPACE_NAME) F 
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+) 
UNION ALL --如果有临时表空间 
SELECT D.TABLESPACE_NAME, 
SPACE || ‘M‘ "SUM_SPACE(M)", 
BLOCKS SUM_BLOCKS, 
USED_SPACE || ‘M‘ "USED_SPACE(M)", 
ROUND (NVL (USED_SPACE, 0) / SPACE * 100, 2) || ‘%‘ "USED_RATE(%)", 
NVL (FREE_SPACE, 0) || ‘M‘ "FREE_SPACE(M)" 
FROM ( SELECT TABLESPACE_NAME, 
ROUND (SUM (BYTES) / (1024 * 1024), 2) SPACE, 
SUM (BLOCKS) BLOCKS 
FROM DBA_TEMP_FILES 
GROUP BY TABLESPACE_NAME) D, 
( SELECT TABLESPACE_NAME, 
ROUND (SUM (BYTES_USED) / (1024 * 1024), 2) USED_SPACE, 
ROUND (SUM (BYTES_FREE) / (1024 * 1024), 2) FREE_SPACE 
FROM V$TEMP_SPACE_HEADER 
GROUP BY TABLESPACE_NAME) F 
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+) 
ORDER BY 1;

oracle 11g 表空间使用率

标签:

原文地址:http://www.cnblogs.com/hankyoon/p/5174547.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!