Greenplum同步到Oracle(转)

开发提出需要从Greenplum同步到Oracle的解决方案,写了个脚本用于定时调度处理。


#!/bin/sh
#copy_gp_2_ora.sh
if [ $# -ne 1 ]; then
    echo "Usage: sh $0 tablename"
    exit 1
fi
TABLENAME=$1
 
psql -h <host> -U <user> <db><<EOF 
\timing off
set client_encoding='gb18030';
\copy $TABLENAME to '/home/oracle/$TABLENAME.txt' csv
\q
EOF
 
echo "load data
infile '$TABLENAME.txt' discardfile '$TABLENAME.dis'
append
into table $TABLENAME
fields terminated by ','                     #域终止符
optionally enclosed by '\"'                #列元素用"包裹
(id)">"$TABLENAME.ctl"
 
sqlldr system/000000 control="$TABLENAME.ctl" log="$TABLENAME.log"
-EOF-

posted @ 2014-07-01 15:50  孤叶情枫  阅读(386)  评论(0编辑  收藏  举报