select a.tablespace_name a1,a.file_name a2,
a.avail a3,nvl(b.free,0) a4,
nvl(round(((free/avail) * 100),2),0) a5
from (select tablespace_name,substr(file_name,1,45) file_name,
file_id,round(sum(bytes/(1024*1024)),3) avail
from dba_data_files
group by tablespace_name,substr(file_name,1,45),file_id) a,
(select tablespace_name,file_id,
round(sum(bytes/(1024*1024)),3) free
from dba_free_space
group by tablespace_name,file_id) b
where a.file_id = b.file_id(+)
union all
select a.tablespace_name a1,a.file_name a2,
a.avail a3,nvl(b.free,0) a4,
nvl(round(((free/avail) * 100),2),0) a5
from (select tablespace_name,substr(file_name,1,45) file_name,
file_id,round(sum(bytes/(1024*1024)),3) avail
from dba_temp_files
group by tablespace_name,substr(file_name,1,45),file_id) a,
(select tablespace_name,file_id,
round(sum(bytes_free/(1024*1024)),3) free
from v$temp_space_header
group by tablespace_name,file_id) b
where a.file_id = b.file_id(+)
order by 1,2;
다른 쿼리 : https://blog.daonelab.com/post/24/434/