informix中简单数据导入导出命令sh程序
Informix数据库自带两个命令:load和unload
我们可根据方便编写sh程序进行数据的导入导出,以下两段sh程序在RedHat Linux AS 4上测试通过,应该适用于大多数Unix,Linux操作系统,放到$INFORMIX_HOME$/bin下,则使用informix登录后就可以随意使用,记得chmod x load和chmod x unload
##!/bin/ksh;
if [ $# -ne 3 ]
then
echo "error: arguments is not enough"
echo "Usage: load dbname filename tablename";
echo "e.g.: load cmsdbs custinfo.unl custinfo";
exit;
fi
dbname=$1;
filename=$2;
tablename=$3;
dbaccess <<!
database $dbname;
load from $filename insert into $tablename;
!
##!/bin/ksh;
if [ $# -ne 3 ]
then
echo "error: arguments is not enough";
echo "Usage: unload dbname filename tablename";
echo "e.g.: unload cmsdbs custinfo.unl custinfo";
exit;
fi
dbname=$1;
filename=$2;
tablename=$3;
dbaccess <<!
database $dbname;
##!/bin/ksh;
if [ $# -ne 3 ]
then
echo "error: arguments is not enough";
echo "Usage: unload dbname filename tablename";
echo "e.g.: unload cmsdbs custinfo.unl custinfo";
exit;
fi
dbname=$1;
filename=$2;
tablename=$3;
dbaccess <<!
database $dbname;
unload to $filename select * from $tablename;
unload to $filename select * from $tablename;