By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,589 Members | 2,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,589 IT Pros & Developers. It's quick & easy.

Execute runstats in a stored procedure

P: 4
Hi,
we want to execute runstats for all database tables in one go.In db2 v9, there is no such option to run runstats schema vise or for complete database.So,can we execute runstats from a stored procedure.
Sep 26 '07 #1
Share this Question
Share on Google+
2 Replies


P: 3
I use a shell script to accomplish what you want. You'll have to modify a bit
for you environment.

#!/usr/bin/ksh

################################################## ##

DBNAME="DBNAME"
TABSCHEMA="MYSCHEMA"

db2 activate db $DBNAME
export DB2DBDFT=$DBNAME

echo "Running..."

db2 connect to $DBNAME user user using pass

db2 -x "select tabname from syscat.tables where tabschema='MYSCHEMA' and TYPE='T'" |
while read TABNAME
do
db2 -v -x "runstats on table $TABSCHEMA.\"$TABNAME\" and indexes all"
done

db2 terminate
Sep 26 '07 #2

P: 14
If you want to runstats on all the tables in the database we can accomplish this with just a single command

Connect to the database and run the follwing command
reorgchk update statistics
Sep 26 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.