Thursday, June 23, 2011

Tablespaces Usage

This script is used to calculate all Tablespaces Usage

SET SERVEROUTPUT ON
SET PAGESIZE 1000
SET LINESIZE 255
SET FEEDBACK OFF

SELECT u.tablespace_name,
u.size_GB total_GB,
u.size_GB - f.free_GB used_GB,
f.free_GB,
(f.free_GB * 100) / u.size_GB "Free Percentage %"
FROM ( SELECT a.tablespace_name, SUM (a.bytes) / 1024 / 1024 / 1024 SIZE_GB
FROM dba_data_files a
GROUP BY a.tablespace_name) u,
( SELECT b.tablespace_name, SUM (b.bytes) / 1024 / 1024 / 1024 FREE_GB
FROM dba_free_space b
GROUP BY b.tablespace_name) f
WHERE u.tablespace_name = f.tablespace_name(+)
ORDER BY f.free_GB;

No comments: