## SQL script to analyze and/or compute database statistics
##
## If the table size is greater than 10 Mb in size, statistics 
## are estimated.

set pages  0
set lines  132
set term   off
set recsep off
spool  /tmp/statistics.tmp

SELECT 'analyze table '||owner||'.'||table_name||' '||
       decode(sign(10485760 - initial_extent),1,'compute statistics;',
                       			        'estimate statistics;') 
FROM   sys.dba_tables
WHERE  owner != 'SYS'
/

spool  off
spool  /tmp/statistics.log
@/tmp/statistics.tmp
spool off
exit

