Saturday, 9 August 2014

Oracle: Find Total Size of The Database

The size of the oracle database is the total size of the data files, redo log files and temp files that make up the tablespaces of the database. These details are found in the dba_extents view. Type the following lines at the SQL prompt:

Total-size-of-oracle-database


Method 1: To find used space within the database.

SQL>select sum(bytes/1024/1024/1024) as SIZE from   dba_extents;

Method 2: To find overall database size:

The biggest portion of a database's size comes under the datafiles.
To get size of all datafiles in MB:

SQL>select sum(bytes)/1024/1024 "Meg" from dba_data_files;
To get the size of all TEMP files:

select nvl(sum(bytes),0)/1024/1024 "Meg" from dba_temp_files;
To get the size of the on-line redo-logs:

select sum(bytes)/1024/1024 "Meg" from sys.v_$log;


Combining all together we will get overall size: 

SQL> select ( select sum(bytes)/1024/1024/1024 data_size from dba_data_files ) +
( select nvl(sum(bytes),0)/1024/1024/1024 temp_size from dba_temp_files ) +
( select sum(bytes)/1024/1024/1024 redo_size from sys.v_$log ) +
( select sum(BLOCK_SIZE*FILE_SIZE_BLKS)/1024/1024/1024 controlfile_size from v$controlfile) "Size in GB"
from
dual


Check Oracle database faq:
http://www.orafaq.com/ 

No comments:

Post a Comment