SELECT a.tablespace_name, --表空间名称
a.bytes bytes_used, --表空间的总字节数
b.largest, --表空间中余下的字节数
round(((a.bytes - b.bytes) / a.bytes)*100, 2) percent_used --已经使用的字节数占总字节数的百分比
FROM
(SELECT tablespace_name,
SUM(bytes) bytes
FROM Dba_Data_Files
GROUP BY tablespace_name) a,
(SELECT tablespace_name,
SUM(bytes) bytes,
MAX(bytes) largest
FROM dba_free_space
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name
ORDER BY ((a.bytes - b.bytes) / a.bytes) DESC;