Tuesday, January 13, 2009

script to calculate free, used and total space and to display in MB

rem :
rem Filename: freespace.sql
rem Purpose: The following script will execute and display the free space faster and saves the user time.
rem Author: Muhammad
rem Date Submitted:21-Jul-2007
rem Date Published:23-Jul-2007
rem


SELECT s.tablespace_name TABLESPACE,
ROUND (((s.ublocks * 8) * 1024) / (1024 * 1024), 0) "USEDMB",
ROUND ((((f.fblocks * 8) * 1024) / (1024 * 1024)), 0) "FREEMB",
ublocks + fblocks "TOTAL BLOCKS",
ROUND (((((ublocks + fblocks) * 8) * 1024) / (1024 * 1024)),
0
) "TOTAL MB"
FROM (SELECT tablespace_name, SUM (blocks) ublocks
FROM dba_segments
GROUP BY tablespace_name) s,
(SELECT tablespace_name, SUM (blocks) fblocks
FROM dba_free_space
GROUP BY tablespace_name) f
WHERE s.tablespace_name = f.tablespace_name
ORDER BY TABLESPACE;

No comments:

Post a Comment