Count of each schema object.

This simple query should list a count of each schema object.

select owner,
max( decode( object_type, 'TABLE', cnt, null ) ) Tables,
max( decode( object_type, 'VIEW', cnt, null ) ) Views,
max( decode( object_type, 'TRIGGER', cnt, null ) ) triggers,
max( decode( object_type, 'PACKAGE', cnt, null ) ) packages
from ( select owner, object_type, count(*) cnt
from dba_objects
group by owner, object_type )
group by owner
/


select *
  from (select owner, object_type, 1 CNT
          from dba_objects ) e
        pivot( sum(CNT) for object_type in
          ( 'INDEX','TYPE','VIEW','LIBRARY','TRIGGER','DIRECTORY','PACKAGE','QUEUE','PACKAGE BODY','TABLE PARTITION','PROCEDURE',
            'WINDOW','CLUSTER','LOB','FUNCTION','CONSUMER GROUP','CONTEXT','RULE','XML SCHEMA','SEQUENCE','INDEX PARTITION','OPERATOR',
            'EVALUATION CONTEXT','SCHEDULE','JOB','SCHEDULER GROUP','LOB PARTITION','JOB CLASS','INDEXTYPE','TABLE','TYPE BODY','RESOURCE PLAN',
            'TABLE SUBPARTITION','UNDEFINED','DESTINATION','SYNONYM','EDITION','PROGRAM','RULE SET' ) )        

order by owner;

Counting all tables in a schem

select table_name, num_rows counter from dba_tables where owner ='IHA' order by table_name

Comments

Popular Posts