首页 > 代码库 > Greenplum同步到Oracle
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-
#!/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-
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。