Friday, November 22, 2013

script that shows tablespace usage in %, blocks used and empty etc

Code:
SELECT RPAD(t.name,18,' ') tablespace ,
LPAD(TO_CHAR(CEIL( (SUM(s.blocks)*COUNT(*)) / (SUM(f.blocks) * 
POWER(COUNT(DISTINCT(f.file#)),2)) * 100 )),3) Pct ,
LPAD(TO_CHAR(TRUNC(SUM(f.blocks) * t.blocksize * 
COUNT(DISTINCT(f.file#)) / 
( COUNT(*) * 1024 * 1024 * 1024 ),2)),6) vol_G ,
LPAD(TO_CHAR(SUM(f.blocks) * t.blocksize * COUNT(DISTINCT(f.file#)) / 
( COUNT(*) * 1024 * 1024 )),8) volume_M ,
TRUNC(SUM(s.blocks) * t.blocksize / 
( 1024 * 1024 * COUNT(DISTINCT(f.file#))),2) taken_M ,
TRUNC( ( SUM(f.blocks) * t.blocksize * COUNT(DISTINCT(f.file#)) 
/ ( COUNT(*) * 1024 * 1024 ) )
- ( NVL(suM(s.blocks),0) * t.blocksize 
/ ( 1024 * 1024 * COUNT(DISTINCT(f.file#)) ) ),2) remain_M
FROM sys.seg$ s, sys.ts$ t, sys.file$ f
WHERE s.ts# (+) = t.ts# 
AND f.ts# = t.ts#
AND f.status$ = 2
GROUP BY t.name, t.blocksize
ORDER BY 1;



Code:
 
TABLESPACE         PCT VOL_G  VOLUME_M    TAKEN_M   REMAIN_M
------------------ --- ------ -------- ---------- ----------
SYSAUX             610    .11      120     731.06    -611.06
SYSTEM             232    .29      300     695.62    -395.62
UNDOTBS1             3    .02       25        .62      24.37
UNDOTBS2             3    .02       25        .62      24.37
USERS                8      0        5        .37       4.62

No comments:

Post a Comment