中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 数据库开发 > 数据库综合
PROGRESS数据库整理以后的数据自动确认
作者:未知 时间:2005-09-13 23:43 出处:Blog.ChinaUnix.net 责编:chinaitpower
              摘要:PROGRESS数据库整理以后的数据自动确认
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
关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有