Wednesday, October 6, 2010

Tablespace Usage

        set term on
        set echo on
        column dummy noprint
        column  pct_used format 999.9       heading "%|Used"
        column  name    format a26      heading "Tablespace Name"
        column  Mbytes   format 999,999,999    heading "MBytes"
        column  used    format 999,999,999   heading "Used"
        column  free    format 999,999,999  heading "Free"
        column  largest    format 999,999,999  heading "Largest"
        column  max_size format 999,999,999 heading "MaxPoss|Mbytes"
        column  pct_max_used format 999.9       heading "%|Max|Used"
        break   on report
        compute sum of Mbytes on report
        compute sum of free on report
        compute sum of used on report
        set linesize 110
        set pagesize 100
        set feed off
        select (select decode(extent_management,'LOCAL','*',' ') from dba_tablespaces
        where tablespace_name = b.tablespace_name) || nvl(b.tablespace_name,nvl(a.tablespace_name,'UNKOWN')) name,
        mbytes_alloc mbytes,mbytes_alloc-nvl(mbytes_free,0) used,nvl(mbytes_free,0) free,
        ((mbytes_alloc-nvl(mbytes_free,0))/mbytes_alloc)*100 pct_used,
        nvl(largest,0) largest,nvl(mbytes_max,mbytes_alloc) Max_Size,
        decode( mbytes_max, 0, 0, (mbytes_alloc/mbytes_max)*100) pct_max_used
        from ( select sum(bytes)/(1024*1024) Mbytes_free,max(bytes)/(1024*1024) largest,tablespace_name
        from  sys.dba_free_space group by tablespace_name ) a, (select sum(bytes)/(1024*1024) Mbytes_alloc,
        sum(maxbytes)/(1024*1024) Mbytes_max, tablespace_name
        from sys.dba_data_files  group by tablespace_name
        union all
        select sum(bytes)/(1024*1024) Mbytes_alloc,sum(maxbytes)/(1024*1024) Mbytes_max,tablespace_name
        from sys.dba_temp_files group by tablespace_name )b
        where a.tablespace_name (+) = b.tablespace_name order by a.tablespace_name asc;

No comments:

Post a Comment