May 15, 2013

SQL script to check the tablespace usage in Oracle Database.

Here is the SQL Script to check the tablespace usage of all the tablespaces in Oracle Database.
It displays in the memory usage in MBs.

SELECT Total.name "Tablespace Name",
nvl(Free_space, 0) "Free Size(MB)",
nvl(total_space-Free_space, 0) "Used Size(MB)",
total_space "Total Size(MB)"
FROM
(select tablespace_name, sum(bytes/1024/1024) free_space
from sys.dba_free_space
group by tablespace_name
) Free,
(select b.name, sum(bytes/1024/1024) total_space
from sys.v_$datafile a, sys.v_$tablespace B
where a.ts# = b.ts#
group by b.name
) Total
WHERE Free.Tablespace_name(+) = Total.name
ORDER BY Total.name;

Source: http://planetofsolutions.blogspot.in/2010/03/how-to-check-tablespace-usage-in-oracle.html

No comments:

Post a Comment