denrepo

OracleStorage

Database size three ways: allocated, used and total

Allocated datafile size, space actually used by segments, and the overall footprint including temp files, online redo logs and control files. All in GB.

Tested on 12c, 19c · verified Sep 2026

ora-db-size.sql
1CLEAR COLUMNS2SET LINESIZE 120 PAGESIZE 100 TRIMOUT ON TAB OFF3 4-- Actual size of the database (allocated datafiles)5SELECT SUM (bytes) / 1024 / 1024 / 1024 AS GB FROM dba_data_files;6 7-- Size occupied by data (segments)8SELECT SUM (bytes)/1024/1024/1024 AS GB FROM dba_segments;9 10-- Overall size: datafiles + temp files + redo logs + control files11select12( select sum(bytes)/1024/1024/1024 data_size from dba_data_files ) +13( select nvl(sum(bytes),0)/1024/1024/1024 temp_size from dba_temp_files ) +14( select sum(bytes)/1024/1024/1024 redo_size from sys.v_$log ) +15( select sum(BLOCK_SIZE*FILE_SIZE_BLKS)/1024/1024/1024 controlfile_size from v$controlfile) "Size in GB"16from17dual;

Save it as ora-db-size.sql and run it with SQL> @ora-db-size.

Open in denrepoRelated tool: Tablespace runway and datafiles

More Oracle scripts: Storage