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-