tablespace 공간 조회 sql
select a.tablespace_name,
totbytes,totblocks,
freebytes, freeblocks,
(totbytes - freebytes) as usedbytes,
(totblocks - freeblocks) as usedblocks
from (
select tablespace_name,
sum(bytes) totbytes,
sum(blocks) totblocks
from dba_data_files
group by tablespace_name -- tbs가 여러개 데이터 파일이 가질 수 있기 때문에 grouping
) a,
(
select tablespace_name,
sum(bytes) freebytes,
sum(blocks) freeblocks
from dba_free_space
group by tablespace_name
) b
where a.tablespace_name = b.tablespace_name;