Oracle Tablespace 資料 ( 大小, 使用率, 最大可使用空間)

0

Oracle 因為有 Autoextend 這個概念,  所以在空間預算上可以伸延(Auto extent )的空間也是不可忽略的一環 , 以下SQL 可以幫助你找到, 現有空間的大小, 使用率 及最大可以伸延的空間:

select a.tablespace_name,
round(a.bytes_alloc / 1024 / 1024, 2) Allocated_Space,
round(nvl(b.bytes_free, 0) / 1024 / 1024, 2) Free_Space,
round((a.bytes_alloc - nvl(b.bytes_free, 0)) / 1024 / 1024, 2) Used_Space,
round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100,2) Free_Percent,
100 - round((nvl(b.bytes_free, 0) / a.bytes_alloc) * 100,2) Used_Percent,
round(maxbytes/1048576,2) "Max(Autoextend Included)"
from ( select f.tablespace_name, sum(f.bytes) bytes_alloc,
sum(decode(f.autoextensible, 'YES',f.maxbytes,'NO', f.bytes)) maxbytes
from dba_data_files f
group by tablespace_name) a,
( select f.tablespace_name, sum(f.bytes) bytes_free
from dba_free_space f
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name (+)
union
select h.tablespace_name,
round(sum(h.bytes_free + h.bytes_used) / 1048576, 2),
round(sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) / 1048576, 2),
round(sum(nvl(p.bytes_used, 0))/ 1048576, 2),
round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
sum(h.bytes_used + h.bytes_free)) * 100,2),
100 - round((sum((h.bytes_free + h.bytes_used) - nvl(p.bytes_used, 0)) /
sum(h.bytes_used + h.bytes_free)) * 100,2),
round(max(h.bytes_used + h.bytes_free) / 1048576, 2)
from sys.v_$TEMP_SPACE_HEADER h, sys.v_$Temp_extent_pool p
where p.file_id(+) = h.file_id
and p.tablespace_name(+) = h.tablespace_name
group by h.tablespace_name
ORDER BY 1;
Share.

About Author

hahahahahaha......nothing here

發表迴響

error: Content is protected !!