Tuesday, May 24, 2011

[DB2] Scripts for Reorg DB , Can't use it on production DB

db2 list tables for schema tpasadm |grep TPASADM | awk '{print $1}' | while read tblname
do
db2 connect to tpas
db2 reorgchk current statistics on table TPASADM.$tblname |grep "Index:" | awk '{print $2}' |while read idxname
do
db2 connect to tpas > /dev/null
printf "Reorg Table $tblname Index $idxname \n"
db2 reorg table TPASADM.$tblname index $idxname inplace allow write access > /dev/null
db2 terminate > /dev/null
done
done

Wednesday, January 12, 2011

Step of DB2 reorg

Table name:SIVIEW.FRLOTNOTE
Index name:siview.IRCAST_LOT

1.runstat
db2 runstats on table SIVIEW.FRLOTNOTE and index all allow write access
2.reorgchk
db2 reorgchk current statistics on table all(or SIVIEW.FRLOTNOTE)
3.reorg
db2 "reorg table SIVIEW.FRCAST_LOT index siview.IRCAST_LOT inplace allow write access"
4.reorg status check
db2pd -d tpas -reorgs |grep FRCAST_LOT
5.reorgchk again(check)
db2 reorgchk current statistics on table all
6.done