Free space in tablespace including the autoextents
Hello,
how can i see how much free space a tablespace has, and that it also takes the autoextents of the datafiles in the calculation.
This is what i use now, to check the freespace, but i think it's inaccurate, because of some datafiles, which can grow, and the scripts doesn't show the max size of the datafiles.
SELECT df.tablespace_name tsname
, sum(df.bytes)/1024/1024 tbs_size_mb
, nvl(sum(e.used_bytes)/1024/1024,0) used
, 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
/
thanks in advance,