oracle 查询 磁盘使用率
SELECT d.tablespace_name "Name",
TO_CHAR(NVL(a.bytes / 1024 / 1024 / 1024, 0), '99,999,990') Size_GB,
TO_CHAR(NVL(a.bytes - NVL(f.bytes, 0), 0) / 1024 / 1024 / 1024,
'999,999,999') Used_GB,
TO_CHAR(NVL(f.bytes / 1024 / 1024 / 1024, 0), '99,999,990') Free_GB,
TO_CHAR(NVL((a.bytes - NVL(f.bytes, 0)) / a.bytes * 100, 0),
'990.00') "% USED",
TO_CHAR(NVL(f.bytes / a.bytes * 100, 0), '990.00') "% FREE"
FROM sys.dba_tablespaces d,
(select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes
from dba_free_space
group by tablespace_name) f
WHERE d.tablespace_name = a.tablespace_name(+)
AND d.tablespace_name = f.tablespace_name(+)
AND NOT
(d.extent_management like 'LOCAL' AND d.contents like 'TEMPORARY')
and TO_CHAR(NVL((a.bytes - NVL(f.bytes, 0)) / a.bytes * 100, 0),
'990.00') > 80
ORDER BY 5 DESC;
---或者
SELECT A.TABLESPACE_NAME,
round(A.BYTES / 1024 / 1024 / 1024, 3) TOTAL_GB,
round(B.BYTES / 1024 / 1024 / 1024, 3) USED_GB,
round(C.BYTES / 1024 / 1024 / 1024, 3) FREE_GB,
round((B.BYTES * 100) / A.BYTES, 3) "% USED",
round((C.BYTES * 100) / A.BYTES, 3) "% FREE"
FROM SYS.SM$TS_AVAIL A, SYS.SM$TS_USED B, SYS.SM$TS_FREE C
WHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME
AND A.TABLESPACE_NAME = C.TABLESPACE_NAME
and (B.BYTES * 100) / A.BYTES > 80;