Find a table size including dependent objects

Use the following query to find the size of a table including its indexes and LOBs.

select name,sum(gb) from(
select case when segment_type in ('TABLE','TABLE PARTITION') then s.SEGMENT_NAME 
when segment_type in ('LOBSEGMENT','LOB PARTITION') then l.TABLE_NAME
when segment_type in ('INDEX','INDEX PARTITION') then i.table_name
else s.SEGMENT_NAME 
end name
,bytes/1024/1024/1024  gb
from dba_segments s left join dba_lobs l on l.segment_name=s.segment_name
left join dba_indexes i on i.index_name=s.segment_name
where segment_type not in ('TYPE2 UNDO','ROLLBACK')
)
group by name
order by 2 desc;

Leave a Reply

Your email address will not be published. Required fields are marked *