Database/Tablespace Free space in MB

One of the most used script used by the DBA in day-to-day work, this script gives the space usage of each tablespace in the database.


set heading on
set pagesize 500
set lines 400

column tablespace       format a30                heading "Tablespace"
column avail            format 9,999,999,999,999  heading "MB Avail."
column used             format 9,999,999,999,999  heading "MB Used"
column free             format 9,999,999,999,999  heading "MB Free"
column pct              format 999                heading "Pct"

compute sum of avail used free on report
break on report
select  a.tablespace_name "Tablespace",
        a.avail,
        a.avail-b.free used,
        b.free,
        round(nvl((a.avail-b.free)/a.avail*100,0))      "Pct"
from
(select tablespace_name, round(sum(bytes)/1048576)     avail
        from    sys.dba_data_files
        group by tablespace_name
        UNION
        select  tablespace_name,round(sum(bytes_free+bytes_used)/1048576)
        from v$temp_space_header
        group by tablespace_name)       a,
(select tablespace_name, round(sum(bytes)/1048576)     free
        from    sys.dba_free_space
        group by tablespace_name
        UNION
        select  tablespace_name,round(sum(bytes_free)/1048576)
        from v$temp_space_header
        group by tablespace_name)       b
where  a.tablespace_name = b.tablespace_name (+);


  • Share/Bookmark

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>