导出
-----------------------------------------------
if [ $# -lt 4 ]
then
echo "Usage: $0 "
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 "
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
-----------------------------------------------