IBM Connections:Reorg Connections Databases
Shell de Criação dos arquivos de reorg
1) Conectar com um usuário com permissão de db2admin
2) Criar o arquivo db2-reorg-tables.sh
#!/bin/bash for DBNAME in BLOGS DOGEAR FILES FORUM HOMEPAGE OPNACT PEOPLEDB SNCOMM WIKIS METRICS COGNOS PNS CCM do db2 connect to $DBNAME db2 reorgchk update statistics on table all > resultado$DBNAME.txt db2 terminate echo "db2 connect to $DBNAME" > reorg$DBNAMETable.txt cat resultadoPEOPLEDB.txt | grep Table: | awk -F: '{ print "db2 reorg table" $2 }' >> reorg$DBNAMETable.txt echo "db2 terminate" >> reorg$DBNAMETable.txt echo "db2 connect to $DBNAME" > reorg$DBNAMEIndex.txt cat resultadoPEOPLEDB.txt | grep Table: | awk -F: '{ print "db2 reorg indexes all for table" $2 }' >> reorg$DBNAMEIndex.txt echo "db2 terminate" >> reorg$DBNAMEIndex.txt sh -x reorg$DBNAMETable.txt sh -x reorg$DBNAMEIndex.txt done
Salvar e fechar
3) Executar o arquivo
sh -x db2-reorg-tables.sh
Exemplos do resultado
db2 connect to PEOPLEDB db2 reorgchk update statistics on table all > resultadoPEOPLEDB.txt db2 terminate echo "db2 connect to PEOPLEDB" > reorgPEOPLEDBTable.txt cat resultadoPEOPLEDB.txt | grep Table: | awk -F: '{ print "db2 reorg table" $2 }' >> reorgPEOPLEDBTable.txt echo "db2 terminate" >> reorgPEOPLEDBTable.txt echo "db2 connect to PEOPLEDB" > reorgPEOPLEDBIndex.txt cat resultadoPEOPLEDB.txt | grep Table: | awk -F: '{ print "db2 reorg indexes all for table" $2 }' >> reorgPEOPLEDBIndex.txt echo "db2 terminate" >> reorgPEOPLEDBIndex.txt sh -x reorgPEOPLEDBTable.txt sh -x reorgPEOPLEDBIndex.txt