Thursday, May 2, 2024

Find Oracle DB table size

To find the size of all the tables in a DB:

select owner, segment_name, sum(bytes)/1024/1024/1024 from dba_segments group by owner, segment_name order by sum(bytes)/1024/1024/1024 desc;


To find the size of a specific table in a DB:

select owner, segment_name, sum(bytes)/1024/1024/1024 from dba_segments where segment_name='&segment_name';


Find Oracle DB name as a normal user

During certain situations, we may be required to find the DB name as a normal user (which does not have 'sysdba' privilege or access on v$/dba views).

In such cases, the below queries will help us with the DB name along with the domain name

select ora_database_name from dual;

select * from global_name;