--
-- Count rows in all existing tables
--
-- Created:   May 26, '99  Stan K
-- Modified:
--            Oct 11, '00  Stan K   Added views
--            Dec  4, '01  Stan K   Added mviews
--                                  Removed mviews since they are included
--                                  to tables !!!
--            Sep 15, '04  Stan K   Explicit ordering of tables and views. 
--
----------------------------------------------------------------------
-- First create count.sql file to do the count
--
set feedback 0
set pages 0
set termout off
set echo off
--
spool count.sql
PROMPT PROMPT TABLES:
select 'select count(*) from '||table_name||';' from user_tables
 order by table_name;
PROMPT PROMPT VIEWS:
select 'select count(*) from '||view_name||';' from user_views
 order by view_name;
--PROMPT PROMPT MVIEWS:
--select 'select count(*) from '||mview_name||';' from user_mviews;
spool off
--
set feedback 6
set pages 14
set termout on
----------------------------------------------------------------------
-- Now run count.sql and log the results and echos of the commands
--
spool ../logs/count.log
set heading off
select 'DATE:  ' || to_char(sysdate, 'DD-MON-YY HH24:MI:SS') from dual;
set heading on
show user
host echo 'ORACLE_SID:' $ORACLE_SID > ../logs/oracle_sid.log
set echo on
@count.sql
set echo off     
spool OFF
--
host cat ../logs/count.log >> ../logs/oracle_sid.log
host mv ../logs/oracle_sid.log ../logs/count.log        
--
