Display tablespace usage
column tsname format a30 heading ‘Tablespace Name’
column tbs_size_mb format 99999,999 heading ‘Size|(MB)’
column used format 99999,999 heading ‘Used|(MB)’
column avail format 99999,999 heading ‘Free|(MB)’
column used_visual format a11 heading ‘Used’
column pct_used format 999 heading ‘% Used’
set linesize 1000;
set trimspool on;
set pagesize 32000;
set verify off;
set feedback off;
PROMPT
PROMPT *************************
PROMPT *** TABLESPACE STATUS ***
PROMPT *************************
SELECT df.tablespace_name tsname
, round(sum(df.bytes)/1024/1024) tbs_size_mb
, round(nvl(sum(e.used_bytes)/1024/1024,0)) used
, round(nvl(sum(f.free_bytes)/1024/1024,0)) avail
, rpad(‘ ‘||rpad(‘X’,round(sum(e.used_bytes)
*10/sum(df.bytes),0), ‘X’),11,’-‘) used_visual
, nvl((sum(e.used_bytes)*100)/sum(df.bytes),0) pct_used
FROM sys.dba_data_files df
, (SELECT file_id
, sum(nvl(bytes,0)) used_bytes
FROM sys.dba_extents
GROUP BY file_id) e
, (SELECT max(bytes) free_bytes
, file_id
FROM dba_free_space
GROUP BY file_id) f
WHERE e.file_id(+) = df.file_id
AND df.file_id = f.file_id(+)
GROUP BY df.tablespace_name
ORDER BY 6;
Will produce results like
XYZ Live Database =================== Size Used Free Tablespace Name (MB) (MB) (MB) Used % Used —————————— ———- ———- ———- ———– —— STATSPACK 2,048 0 2,047 ———- 0 TOOLS 1,024 0 1,024 ———- 0 ACF_XYZ 2,048 0 2,048 ———- 0 ACF_IABC 2,048 3 2,045 ———- 0 UNDOTBS1 1,024 337 449 XXX——- 33 SYSTEM 1,024 557 467 XXXXX—– 54 SYSAUX 5,000 2,738 1,032 XXXXX—– 55 USERS 14,000 9,210 2,678 XXXXXXX— 66 UNDOTBS2 1,024 703 20 XXXXXXX— 69 UNDOTBS3 1,024 740 5 XXXXXXX— 72 |
Leave a Reply
You must be logged in to post a comment.