PROGRESS数据库整理以后的数据自动确认

发表于:2007-06-07来源:作者:点击数: 标签:
PROGRESS 数据库 优化的一个很有效的途径,就是把所有数据表数据导出来,然后再新建一个同名数据库,再把数据导进去,然后做索引重建,我们把这种行为叫做吃饱了撑着(哈哈,当然不是啦,叫DBRe-filing)!这样做的最大好处是: 1、减少了数据库的容量; 2、
PROGRESS数据库优化的一个很有效的途径,就是把所有数据表数据导出来,然后再新建一个同名数据库,再把数据导进去,然后做索引重建,我们把这种行为叫做吃饱了撑着(哈哈,当然不是啦,叫DB Re-filing)!这样做的最大好处是:
1、减少了数据库的容量;
2、提高数据库性能
但是这样一个过程是很繁琐的,特别是对比前后数据库的记录,如果数据表很多的时候!
本文内容部分,就是一个shell脚本,用来自动确认数据库re-filing前后的数据是否一致。
QAD的MFG/PRO系统一般有个菜单用来打印数据库容量,可以利用这个功能,对比re-filing前后的运行结果------

#!/usr/bin/sh

# DB-Refiling Tables & Records Checking

# ---Old file ---New file





#Set default file(s)



if [ "" = "" ]

then

old_file="actdb.prn"

else

old_file=

fi



if [ "" = "" ]

then

new_file="actdbnew.prn"

else

new_file=

fi



#Check if the two files are exist



cd /mfg/ptmp

if [ ! -f ./$old_file ]

then 

echo "Warning: $old_file does not exist!"

exit 

fi

if [ ! -f ./$new_file ]

then

echo "Warning: $new_file does not exist!"

exit 

fi



echo "Start checking tables......"



# Get old tables

more $old_file|grep -v "mgdbrp.p"|grep -v "Networks" >./$$.dbref

more $$.dbref|grep -v "/"|grep -v "root"|tr -d "," >./$$.dbref1

awk '>=0 && <=10000000 {print  " " }' $$.dbref1 >./$$.dbref1i

old_tbl=`more $$.dbref1i|wc -l`



# Get new tables

more $new_file|grep -v "mgdbrp.p"|grep -v "Networks" >./$$.dbref

more $$.dbref|grep -v "/"|grep -v "root"|tr -d "," >./$$.dbref2

awk ' >=0 &&  <= 10000000 {print  " " }' $$.dbref2 >./$$.dbref2i

new_tbl=`more $$.dbref2i |wc -l`



echo "There are $old_tbl tables in the old DB!"

echo "There are $new_tbl tables in the new DB!"



echo "Done!"



if [ $old_tbl -eq $new_tbl ]

then

echo "Congratulation, the number of the tables is same!"

else

echo "Error: the number of the tables is different!"

fi



echo ""

echo "Start checking records......"



nerror=0



# Check records of each table

awk ' >= 0 &&  <= 10000000 {print  " " }' $$.dbref1i |while read tlo cnto

do

cntn=`grep -i "^$tlo " $$.dbref2i|awk '{print }'`

if [ ! "$cntn" = "$cnto" ]

then

echo "The records of $tlo changed! "$cntn" <== "$cnto"" 

let nerror=$nerror+1

fi

done



echo "Done!"



if [ $nerror -ne 0 ]

then

echo "Errors:there are $nerror table(s)' records different!"

else

echo "Contrats! Records dump & load OK."

fi



# Clearing temp

rm $$.dbref

rm $$.dbref1

rm $$.dbref2

rm $$.dbref1i

rm $$.dbref2i

unset old_file

unset new_file

unset old_tbl

unset new_tbl

unset nerror

原文转自:http://www.ltesting.net