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-
相关推荐
89244553 2020-06-11
数据齿轮 2019-12-29
morexyoung 2019-12-26
huolan 2019-12-26
hulao 2019-11-12
herosen 2019-03-19
changjiang 2016-11-08
架构师必备技能 2019-06-28
CSDN研发技术 2019-06-20
biba 2019-06-20
liangshine 2017-10-29
guodaoying 2017-06-14
neverstopforcode 2016-09-23
淮南草 2016-09-08
shisongsong 2019-03-08
KaiZhaoKZ 2016-06-03
wumingxiaozei 2018-02-10
89427418 2017-12-24
tuzhutuzhu 2016-11-09