批处理文件runstat.bat
-------------------------------------
@echo off
set SQLFILE=c:\runstat.sql
set LOGFILE=c:\runstat.log
rem 连接数据库
db2 connect to dbname
rem 生成SQL语句
db2 -x -m "select 'runstats on table '||rtrim(creator)||'.'||name||' and indexes all;' from sysibm.systables where creator='XX' and type='T' order by name asc" > %SQLFILE%
rem 执行SQL语句
db2 -tvf %SQLFILE% -l %LOGFILE%
rem 断开连接
db2 terminate
调用runstat.bat批处理文件
--------------------------------------
@echo off
db2cmd runstat.bat
最后,通过windows定时任务执行runstat.bat即可实现定时收集统计信息。修改SQL语句即可完成其他定时任务。
定时收集统计信息
最新推荐文章于 2022-02-07 09:35:12 发布