PROMPT $RMINC_TOP/sql/RMINC_delete_stat.sql
PROMPT 
PROMPT Runs          $RMINC_TOP/sql/RMINC_delete_statistics.sql
PROMPT Analyze SYS & SYSTEM Objects With Delete Statistics (RMINC)
PROMPT Copyright 2000, All Rights Reserved, Reed-Matthews, Inc.
PROMPT
PROMPT Deletes statistics for objects owned by SYS or SYSTEM
PROMPT Although this application uses Rule-based optimization
PROMPT in the init.ora file, there are some places where
PROMPT cost-based optimization is turned on when hints are used in
PROMPT the application code.  Cost-based optimization requires 
PROMPT analyzed data to work correctly. You aren't supposed to
PROMPT analyze objects owned by SYS or SYSTEM
PROMPT
PROMPT APPS runs this, so APPS must have ANALYZE ANY permission:
PROMPT as user SYS:
PROMPT grant analyze any to apps;
set linesize 180
set pagesize 200
clear buffer
set head off
set termout off
set feedback off
spool &1..RMINC_delete_statistics.sql;
select 'whenever sqlerror continue' from dual;
select 'ANALYZE TABLE '||owner||'.'||table_name||' DELETE STATISTICS;'
        from all_tables
    where owner in ('SYS','SYSTEM')
    and last_analyzed is not null;
select 'PROMPT ALL DONE' from dual;
spool off;
spool &1
set echo on
set termout on
set feedback on
@&1..RMINC_delete_statistics.sql
host rm &1..RMINC_delete_statistics.sql
exit;

