col "Tablespace" for a22col "Used MB" for 9,999,999.99col "Free MB" for 9,999,999.99col "Total MB" for 9,999,999.99col Extend_free_space for 9,999,999.99col "Pct Free" for 999,999.99col "Max Space" for 999,999.99set linesize 120select df.tablespace_name "Tablespace",totalusedspace "Used MB",(df.totalspace - tu.totalusedspace) "Free MB",df.totalspace "Total MB",round(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace),2)"Pct. Free"from(select tablespace_name,round(sum(bytes) / 1048576) TotalSpacefrom dba_data_filesgroup by tablespace_name) df,(select round(sum(bytes)/(1024*1024)) totalusedspace, tablespace_namefrom dba_segmentsgroup by tablespace_name) tuwhere df.tablespace_name = tu.tablespace_name;select df.tablespace_name "Tablespace",nvl(totalusedspace,0) "Used MB",(df.totalspace - nvl(tu.totalusedspace,0)) "Free MB",df.totalspace "Total MB",round(100 * ( (df.totalspace - nvl(tu.totalusedspace,0))/ df.totalspace),2)"Pct. Free",nvl(fs.free_space,0) extendable_free_space, round(maxspace,2) maxspacefrom(select tablespace_name,round(sum(bytes) / 1048576) TotalSpace, sum(maxbytes)/1024/1024 maxspacefrom dba_data_filesgroup by tablespace_name) df,(select round(sum(bytes)/(1024*1024)) totalusedspace, tablespace_namefrom dba_segmentsgroup by tablespace_name) tu,(select tablespace_name, round(sum(bytes)/1024/1024 ,2) as free_spacefrom dba_free_spacegroup by tablespace_name) fswhere df.tablespace_name = tu.tablespace_name(+)AND df.tablespace_name = fs.tablespace_name(+)ORDER BY "Pct. Free";
DBA Learning
Monday, November 4, 2019
Find Tablespace Size
Subscribe to:
Posts (Atom)