oracle tablespace
SELECT a.tablespace_name,
ROUND(a.BYTES, 2) "已使用(G)",
ROUND(b.BYTES, 2) "未使用(G)",
ROUND(((a.BYTES - b.BYTES) / a.BYTES) * 100, 2) "使用率%"
FROM (SELECT tablespace_name,
SUM(BYTES) /(1024 * 1024 * 1024) BYTES
FROM dba_data_files
GROUP BY tablespace_name) a,
(SELECT tablespace_name,
SUM(BYTES) /(1024 * 1024 * 1024) BYTES
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;