Oracle查詢表空間使用情況
阿新 • • 發佈:2019-01-07
通過dba_data_files 與dba_free_space 按照tablespace_name分組統計,然後進行關聯即可select c.tablespace_name "表空間",
c.total "表空間總大小(M)",
c.total - d.free "已使用大小(M)",
nvl(d.free, 0) "空閒大小(M)",
round((c.total - d.free) / c.total, 4) * 100 || '%' "使用佔比(%)"
from (select tablespace_name, round(sum(a.bytes) / (1024 * 1024), 2) total
from dba_data_files a
group by a.tablespace_name) c
left join (select b.tablespace_name,
round(sum(b.bytes) / (1024 * 1024), 2) free
from dba_free_space b
group by b.tablespace_name) d on c.tablespace_name =
d.tablespace_name
/* where c.tablespace_name like '%UNDOTBS%' 查詢指定表空間使用情況*/
order by 4 desc
c.total "表空間總大小(M)",
c.total - d.free "已使用大小(M)",
nvl(d.free, 0) "空閒大小(M)",
round((c.total - d.free) / c.total, 4) * 100 || '%' "使用佔比(%)"
from (select tablespace_name, round(sum(a.bytes) / (1024 * 1024), 2) total
from dba_data_files a
group by a.tablespace_name) c
left join (select b.tablespace_name,
round(sum(b.bytes) / (1024 * 1024), 2) free
from dba_free_space b
group by b.tablespace_name) d on c.tablespace_name =
d.tablespace_name
/* where c.tablespace_name like '%UNDOTBS%' 查詢指定表空間使用情況*/
order by 4 desc