Posted on 2008-08-17 08:18
默认为零 阅读(691)
评论(0) 编辑 收藏 所属分类:
技术
导出
-----------------------------------------------
if [ $# -lt 4 ]
then
echo "Usage: $0 <table_name> <dbname> <dbuser> <dbpwd>"
exit 1
fi
TBL=$1
EXP=$1.data
db2 connect to $2 user $3 using $4
db2 "export to $EXP of del modified by coldel: select * from $TBL with ur" > unload.log
nexp=`grep "Number of rows exported" unload.log | awk -F: '{print $2}'`
echo " ok ! ($nexp)\n"
db2 connect reset > /dev/null
rm -f unload.log
-----------------------------------------------
导入
-----------------------------------------------
if [ $# -lt 4 ]
then
echo "Usage: $0 <table_name> <dbname> <dbuser> <dbpwd>"
exit 1
fi
TBL=$1
DATA=$1.data
EXP=$1.exp
sed 's/:$//g' $DATA > $EXP
chmod a+r $EXP
db2 connect to $2 user $3 using $4
db2 "load from $EXP of del modified by coldel: usedefaults replace into $TBL nonrecoverable" > load.log
nread=`grep "Number of rows read" load.log | awk -F= '{print $2}'`
nload=`grep "Number of rows committed" load.log | awk -F= '{print $2}'`
echo " ok ! ($nread/$nload)\n"
rm -f $EXP
db2 connect reset > /dev/null
rm -f load.log
-----------------------------------------------