SELECT a.tablespace_name "表空间名",
total "表空间大小",
free "表空间剩余大小",
(total - free) "表空间使用大小",
total / (1024 * 1024 * 1024) "表空间大小(G)",
free / (1024 * 1024 * 1024) "表空间剩余大小(G)",
(total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)",
round((total - free) / total, 4) * 100 "使用率 %"
FROM (SELECT tablespace_name, SUM(bytes) free
FROM dba_free_space
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes) total
FROM dba_data_files
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name;
-------------------------查看临时表空间-------------------------------------------------------------
select c.tablespace_name,
to_char(c.bytes / 1024 / 1024 / 1024, '99,999.999') total_gb,
to_char((c.bytes - d.bytes_used) / 1024 / 1024 / 1024, '99,999.999') free_gb,
to_char(d.bytes_used / 1024 / 1024 / 1024, '99,999.999') use_gb,
to_char(d.bytes_used * 100 / c.bytes, '99.9900') || '%' use
from (select tablespace_name, sum(bytes) bytes
from dba_temp_files
GROUP by tablespace_name) c,
(select tablespace_name, sum(bytes_cached) bytes_used
from v$temp_extent_pool
GROUP by tablespace_name) d
where c.tablespace_name = d.tablespace_name;