← Space Management
Oracle · Space Management
How to check the total database size in Oracle
Check the total size of an Oracle database in GB: used, free, and allocated, from the datafiles, tempfiles, redo logs, and free space.
Tested on11g12c19c21c23ai26ai
Run as a user with access to the V$ views and DBA_FREE_SPACE (SYS, SYSTEM, or a monitoring role).
col "Database Size" format a20
col "Free space" format a20
col "Used space" format a20
select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || ' GB' "Database Size"
, round(sum(used.bytes) / 1024 / 1024 / 1024 ) -
round(free.p / 1024 / 1024 / 1024) || ' GB' "Used space"
, round(free.p / 1024 / 1024 / 1024) || ' GB' "Free space"
from (select bytes
from v$datafile
union all
select bytes
from v$tempfile
union all
select bytes
from v$log) used
, (select sum(bytes) as p
from dba_free_space) free
group by free.p
/spacedatabase-sizev$datafile