现在临时的总大小有了,总的使用数也有了,可以将步骤4和步骤6的两个汇总查询作为子查询连接起来查,计算使用百分比,执行以下语句:
select a.tablespace_name,
to_char(a.bytes / 1024 / 1024, '99,999.999') total_bytes,
to_char(b.bytes_used / 1024 / 1024, '99,999.999') use_bytes,
to_char(b.bytes_used * 100 / a.bytes, '99.99') || '%' use
from (select tablespace_name, sum(bytes) bytes
from dba_temp_files
group by tablespace_name) a,
(select tablespace_name, sum(bytes_cached) bytes_used
from v$temp_extent_pool
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
计算用tablespace_name关联计算表空间的使用率并除以两次1024换算成M。