본문 바로가기

DataBase/Oracle

ORACLE TABLE SPACE 사용량 확인쿼리

select   substr(a.tablespace_name,1,30) tablespace,
         round(sum(a.total1)/1024/1024,1) "TotalMB",
         round(sum(a.total1)/1024/1024,1)-round(sum(a.sum1)/1024/1024,1) "UsedMB",
         round(sum(a.sum1)/1024/1024,1) "FreeMB",
         round((round(sum(a.total1)/1024/1024,1)-round(sum(a.sum1)/1024/1024,1))/round(sum(a.total1)/1024/1024,1)*100,2) "Used%"
from
         (select   tablespace_name,0 total1,sum(bytes) sum1,max(bytes) MAXB,count(bytes) cnt
          from     dba_free_space
          group by tablespace_name
          union
          select   tablespace_name,sum(bytes) total1,0,0,0
          from     dba_data_files
          group by tablespace_name) a
group by a.tablespace_name
order by tablespace;


--테이블스페이스 현황보기(덤으로)
SELECT
sysdate inst_date ,
ddf.tablespace_name tspace ,
ROUND(fst.FRAG_INDEX,2) fragindex ,
allspc.KB totalaloc ,
(ddf.fretot - fst.total_free ) /1024 totalused ,
fst.total_free /1024 totalfree ,
ROUND((fst.total_free /ddf.fretot),2) * 100 frepct ,
fst.max_hole /1024 maxdiv ,
ROUND((fst.avg_hole /1024),2) avgdiv ,
fst.holes num_of_div
FROM dual,
(SELECT
tablespace_name tablespace_name ,
SUM(bytes) fretot
FROM dba_data_files
WHERE tablespace_name != 'TEMP'
group by tablespace_name) ddf,
(
SELECT tablespace_name tablespace_name,
SQRT(MAX(BLOCKS)/SUM(BLOCKS))*(100/SQRT(SQRT(COUNT(BLOCKS)) ))
FRAG_INDEX,
SUM(bytes) total_free,
MAX(bytes) max_hole,
AVG(bytes) avg_hole,
COUNT(*) holes
FROM dba_free_space
WHERE tablespace_name != 'TEMP'
GROUP BY tablespace_name
) fst,
(select table_space tablespace_name , sum(x) KB from
(select tablespace_name table_space,sum(BYTES/1024) x from
dba_data_files
where maxbytes=0 and
tablespace_name != 'TEMP'
group by tablespace_name
union all
select tablespace_name table_space,sum(MAXBYTES/1024) x from
dba_data_files
where tablespace_name != 'TEMP'
group by tablespace_name
)group by table_space) allspc
WHERE ddf.tablespace_name = fst.tablespace_name(+)
and ddf.tablespace_name = allspc.tablespace_name(+);

'DataBase > Oracle' 카테고리의 다른 글

Optimizer :  (0) 2008.12.11
유용한 오라클 스크립트  (0) 2008.11.21
테이블전체사용량알아보기  (0) 2008.11.21
게시판 페이징하기  (0) 2008.11.13
[펌] 유용한 Oracle 스크립트  (0) 2008.11.11