1. 程式人生 > >Oracle 檢視大表

Oracle 檢視大表



select owner, table_name, sum(size_m)
  from (select s.owner,
               s.segment_name as table_name,
               s.bytes / 1024 / 1024 as size_m
          from dba_segments s, dba_tables t
         where s.owner = t.owner
           and s.segment_name = t.table_name
        union
        select s.owner,
               l.table_name as table_name,
               s.bytes / 1024 / 1024 as size_m
          from dba_segments s, dba_lobs l
         where s.owner = l.owner
           and s.segment_name = l.segment_name
        union
        select s.owner,
               i.table_name as table_name,
               s.bytes / 1024 / 1024 as size_m
          from dba_segments s, dba_indexes i
         where s.owner = i.owner
           and s.segment_name = i.index_name
        union
        select s.owner,
               p.table_name as table_name,
               s.bytes / 1024 / 1024 as size_m
          from dba_segments s, dba_tab_partitions p
         where s.owner = p.table_owner
           and s.segment_name = p.partition_name)
 group by owner, table_name
 order by sum(size_m) desc