Monday, 3 December 2012

Schema info

How to get details of a schema including objects and their counts?



rum as the user:


select object_type,count(*)
from user_objects
group by object_type
order by object_Type desc;


How to check the size and total no. of objects owned by all schemas in a db?


run from sys:


set pages 999
col "size MB" format 999,999,999
col "size GB" format 999,99
col "Objects" format 999,999,999
select    obj.owner "Owner"
,    obj_cnt "Objects"
,    decode(seg_size_gb, NULL, 0, seg_size_gb) "size GB"
,decode(seg_size, NULL, 0, seg_size) "size MB"
from     (select owner, count(*) obj_cnt from dba_objects group by owner) obj
,    (select owner,ceil(sum(bytes)/1024/1024/1024) seg_size_GB, ceil(sum(bytes)/1024/1024) seg_size
    from dba_segments group by owner) seg
where     obj.owner  = seg.owner(+)
order    by 3 desc ,2 desc, 1;
/


 /****   To find size of a Table or table partition  ********/..


run as sys:



  select
  owner as "Schema"
  , segment_name as "Object Name"
  , segment_type as "Object Type"
  , round(bytes/1024/1024,2) as "Object Size (Mb)"
  , tablespace_name as "Tablespace"
from dba_segments
where owner like 'SCHEMA' 
and segment_type like '%TABLE%'
and segment_name like 'Name of the table'
order by segment_name





*****************

No comments:

Post a Comment