首页 > 数据库 > 数据库开发技术 > 分析表的crontab脚本
将分析表的语句写入一个sh脚本中,然后在crontab中执行这个sh脚本,脚本内容如下:
year=`date +%Y`
month=`date +%m`
day=`date +%d`
now=$year-$month-$day
export ORACLE_SID=orcl
sqlplus '/as sysdba' <
set echo off;
set heading off;
set pagesize 0;
set linesize 1000;
set numwidth 12;
set termout off;
set trimspool on;
spool ${now}.log;
exec dbms_stats.GATHER_TABLE_STATS('scott','emp',cascade=>true,force=>true);
spool off;
exit;
EOF
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22049049/viewspace-1029104/ ,如需转载,请注明出处,否则将追究法律责任。