s/constraint \"informix\".n0/constraint \"informix\".not0/g s/constraint \"informix\".n1/constraint \"informix\".not1/g s/constraint \"informix\".n2/constraint \"informix\".not2/g s/constraint \"informix\".n3/constraint \"informix\".not3/g s/constraint \"informix\".n4/constraint \"informix\".not4/g s/constraint \"informix\".n5/constraint \"informix\".not5/g s/constraint \"informix\".n6/constraint \"informix\".not6/g s/constraint \"informix\".n7/constraint \"informix\".not7/g s/constraint \"informix\".n8/constraint \"informix\".not8/g s/constraint \"informix\".n9/constraint \"informix\".not9/g " > $scriptfname echo "为informix自动定义的约束改名" echo "为informix自动定义的约束改名" >>$logfname for recline in `cat $inputfname` do dbname=`expr substr "$recline" 2 22` if [ -z "$dbname" ] then continue fi echo "\t$dbname . . ." echo "\t$dbname . . ." >>$logfname sqlfname="$dbname.exp/$dbname.sql" if [ ! -s "$sqlfname.bak" ] then cp $sqlfname $sqlfname.bak sed -f $scriptfname $sqlfname > $sedfname cp $sedfname $sqlfname fi done
}
importdb() { echo "\n上载数据库($INformIXSERVER) Begin : `date`" >>$logfname
echo "1> 装载数据库结构" echo "\n1> 装载数据库结构" >>$logfname count=0 maxcount=10 ## 最大失败上载次数 while true echo "循环次数=$count" >>$logfname for recline in `cat $inputfname` do isontape=`expr substr "$recline" 1 1` dbname=`expr substr "$recline" 2 20` if [ -z "$isontape" ] then isontape=0 fi if [ -z "$dbname" ] then continue fi echo "\t$dbname . . . "
isql - - /dev/null drop database $dbname; create database $dbname with log; !
dbaccess $dbname $dbname.exp/$dbname.sql 1>/dev/null 2>$msgfname if [ $? -eq 0 ] then echo "Database=$dbname . . . Success" >>$logfname echo "$isontape$dbname" >> $successfname else echo "Database=$dbname . . . Fail" >>$logfname echo "$isontape$dbname" >> $failfname fi if [ $count -eq $maxcount ] then cat $msgfname >> $logfname fi done do count=`expr $count + 1` if [ $count -gt $maxcount ] then break else if [ -s $failfname ] then mv $failfname $inputfname cat /dev/null > $failfname else break fi fi done
echo "2> 装载成功的数据库数据" echo "2> 装载成功的数据库数据" >>$logfname for recline in `cat $successfname` do isontape=`expr substr "$recline" 1 1` dbname=`expr substr "$recline" 2 20` if [ -z "$isontape" ] then isontape=0 fi if [ -z "$dbname" ] then continue fi echo "\t$dbname . . ."
if [ "$isontape" != "0" ] then echo "ontape -a . . ." >> $logname echo "\ny\n"|ontape -a 1>>$logname 2>&1 fi
isql - - /dev/null drop database $dbname; ! dbimport -l $dbname 1>$msgfname 2>&1 if [ "$?" = "0" ] then echo "Database=$dbname . . . Success" >>$logfname else echo "Database=$dbname . . . Fail" >>$logfname cat $msgfname >>$logfname fi done
if [ ! -e "$inputfname" ] then cat /dev/null >$inputfname fi if [ ! -e "$sedfname" ] then cat /dev/null >$sedfname fi if [ ! -e "$scriptfname" ] then cat /dev/null >$scriptfname fi if [ ! -e "$successfname" ] then cat /dev/null >$successfname fi if [ ! -e "$failfname" ] then cat /dev/null >$failfname fi
选项: 1> 用dbexport备份 2> 用dbimport恢复 3> 删除所有的库 0> 退 出 选择:\c" read mainoptions do if [ "$mainoptions" = "0" ] then break fi if [ -z "$INformIXDIR" ] then echo "没有设置INformIXDIR环境变量" sleep 1 continue fi if [ -z "$INformIXSERVER" ] then echo "没有设置INformIXSERVER环境变量" sleep 1 continue fi if [ -z "$WorkDir" ] then echo "没有设置WorkDir环境变量" sleep 1 continue fi if [ \( ! -d "$WorkDir" \) -o \( ! -w "$WorkDir" \) ] then echo "WorkDir指定的目录必须有读写权限" sleep 1 if [ ! -d "$WorkDir" ] then echo "创建目录$WorkDir . . ." mkdir $WorkDir else continue fi fi case "$mainoptions" in '1' ) cd $WorkDir exportmain ;; '2' ) cd $WorkDir importmain ;; '3' ) isql sysmaster - /dev/null unload to "DelDatabase.txt"" delimiter "" select name from sysdatabases where name not in ("sysmaster", "sysutils"); ! for dbname in `cat DelDatabase.txt` do if [ -z "$dbname" ] then continue fi echo "删除$dbname . . ." isql - - /dev/null drop database $dbname; ! done ;;
# # 下载数据库服务器中全部库名列表 # unloaddblist() { echo ` isql sysmaster - "$expalldbfname" delimiter "" select name from sysdatabases where name not in ("sysmaster", "sysutils"); !` }