SQL @ DjangoSpin

Oracle/SQL: Calculating sizes of different tablespaces in an Oracle database

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon
Reading Time: 1 minutes

Calculating sizes of different tablespaces in Oracle

Calculating sizes of different tablespaces in Oracle:

select 
    b.tablespace_name, 
    b.tbs_size_in_mb "Total size of tablespace in MB", 
    b.tbs_size_in_tb "Total size of tablespace in TB", 
    a.free_space_in_mb "Free space in tablespace in MB", 
    a.free_space_in_tb "Free space in tablespace in TB"
from 
    (select tablespace_name, 
     round(sum(bytes)/1024/1024, 2) as free_space_in_mb, 
     round(sum(bytes)/1024/1024/1024, 2) as free_space_in_tb
     from dba_free_space
     group by tablespace_name) a,
     (select tablespace_name, 
      sum(bytes)/1024/1024 as tbs_size_in_mb, 
      sum(bytes)/1024/1024 as tbs_size_in_tb
      from dba_data_files
      group by tablespace_name) b
where a.tablespace_name(+)=b.tablespace_name;

-- If you notice any commas in the results, those are decimal points.
Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon

Leave a Reply