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

No comments: