Saturday, August 1, 2015

Size of oracle database

#Database size is actually the sum of data files, log files, temp files  and control files.
This query will give us the total db size in GB.

select a.data_size+b.temp_size+c.redo_size+d.controlfile_size "Total_DB_Size in GB"
from ( select sum(bytes)/1024/1024/1024 data_size
from dba_data_files) a,
( select nvl(sum(bytes),0)/1024/1024/1024 temp_size
from dba_temp_files ) b,
( select sum(bytes)/1024/1024/1024 redo_size
from sys.v_$log ) c,
( select sum(BLOCK_SIZE*FILE_SIZE_BLKS)/1024/1024/1024 controlfile_size
from v$controlfile) d;

#OR simply(Excluding control files since its very small in size compared to the database size): 

select sum(bytes)/1024/1024/2014 DB_SIZE_GB from
( select sum (bytes) bytes from v$datafile
  union
  select sum (bytes) from v$tempfile
  union
  select sum (bytes * members) from v$log

)

No comments:

Post a Comment