[db2inst1@localhost ~]$ db2level
DB21085I Instance "db2inst1" uses "64" bits and DB2 code release "SQL09070"
with level identifier "08010107".
Informational tokens are "DB2 v9.7.0.0", "s090521", "LINUXAMD6497", and Fix
Pack "0".
Product is installed at "/opt/ibm/db2/V9.7".
[db2inst1@localhost ~]$ db2 connect to HIS
Database Connection Information
Database server = DB2/LINUXX8664 9.7.0
SQL authorization ID = DB2INST1
Local database alias = HIS
[db2inst1@localhost ~]$
[db2inst1@localhost ~]$ db2 -x "select 'RUNSTATS ON TABLE '||RTRIM(Ltrim(TABLE_SCHEMA))||'.'||RTRIM(Ltrim(TABLE_NAME))||' with distribution and detailed indexes all' from SYSIBM.TABLES WHERE TABLE_SCHEMA='HIS' and TABLE_TYPE='BASE TABLE'" > t.sql
[db2inst1@localhost ~]$ more t.sql
RUNSTATS ON TABLE HIS.T with distribution and detailed indexes all
RUNSTATS ON TABLE HIS.FUND_DAILY with distribution and detailed indexes all
RUNSTATS ON TABLE HIS.FUND_DAILY_INCOME with distribution and detailed indexes all
RUNSTATS ON TABLE HIS.T1 with distribution and detailed indexes all
RUNSTATS ON TABLE HIS.T2 with distribution and detailed indexes all
[db2inst1@localhost ~]$ pwd
/home/db2inst1
[db2inst1@localhost ~]$ nohup db2 -f /home/db2inst1/t.sql > ./runstat_t.log &
[1] 2259
[db2inst1@localhost ~]$ nohup: ignoring input and redirecting stderr to stdout
[db2inst1@localhost ~]$
[db2inst1@localhost ~]$
[1]+ Done nohup db2 -f /home/db2inst1/t.sql > ./runstat_t.log
[db2inst1@localhost ~]$
[db2inst1@localhost ~]$ tail -f runstat_t.log
DB20000I The RUNSTATS command completed successfully.
DB20000I The RUNSTATS command completed successfully.
DB20000I The RUNSTATS command completed successfully.
DB20000I The RUNSTATS command completed successfully.
DB20000I The RUNSTATS command completed successfully.
查看记录:
select tabname,card from syscat.tables where tabschema = 'HIS' and type='T'order by tabname asc;
select name,card from sysibm.systables where creator = 'HIS' and type='T' order by name asc;
相关参考:
http://blog.sina.com.cn/s/blog_4b8cae1a0102va4n.html
https://blog.csdn.net/jycjyc/article/details/100651282