crontab gather stats

$ cat gather_stat.sh
export ORACLE_SID=orcl

export ORACLE_BASE=/opt/oracle

export ORACLE_HOME=/opt/oracle/product/10.2.0.5

export PATH=/opt/oracle/product/10.2.0.5/bin:/usr/local/bin:/bin:/usr/bin:.

sqlplus sys/sys as sysdba << EOF > /home/oracle/gather_stat.log

@$1

@/home/oracle/gather.sql

exit

EOF
++++++++++++++++++++++++++++++++++++++++++

$ cat stats_gather.sql
set pages 100

set lines 250

set echo off feedback off heading off

spool gather.sql

select 'SET ECHO ON FEEDBACK ON TIMING ON' FROM DUAL;

select 'exec dbms_stats.gather_table_stats (ownname => ''' || owner ||''', tabname => '''||table_name||''', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, cascade => TRUE,method_opt => '''||' FOR ALL COLUMNS SIZE AUTO'''||', degree => 8);' from  dba_tables
where owner in ('DFIADMIN', 'S3PUBLISH');

spool off

+++++++++++++++++++++++++++++++++++++++++++++++++

#gather stats for schema in database orcl
* 5 * * 0 /home/oracle/gather_stat.sh /home/oracle/stats_gather.sql > /home/oracle/gather_stat.log



Comments

Popular posts from this blog

Installing DBMS_JAVA package in Oracle and calling UTL_DBWS web services through Oracle database

Starting background process GTX4 and GLOBAL_TXN_PROCESSES

upgrade database oracle 10g to oracle 11g