db2 reorg,runstats

zchbaby2000發表於2018-10-29

db2 -x "select 'reorgchk update statistics on table ' || rtrim(tabschema)||'.'||rtrim(tabname) || ';' from syscat.tables where type = 'T' " > reorgchk.sql
db2 -x "select 'reorgchk current statistics on table ' || rtrim(tabschema)||'.'||rtrim(tabname) || ';' from syscat.tables where type = 'T' " > reorgchk.sql
db2 -tvf reorgchk.out

db2 -x "select 'runstats on table ' || rtrim(tabschema)||'.'||rtrim(tabname) || ' on all columns with distribution on all columns and indexes all allow write access;'from syscat.tables where type = 'T' " > runstats.sql
db2 -tvf runstats.sql

db2 -x "select 'rebind package ' || trim(PKGSCHEMA) || '.' || trim(PKGNAME) || ';'  from syscat.packages" > rebind.sql
db2 -tvf rebind.sql


db2 reorgchk current statistics on table all

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/725820/viewspace-2217912/,如需轉載,請註明出處,否則將追究法律責任。