码迷,mamicode.com
首页 > 数据库 > 详细

Greenplum同步到Oracle

时间:2016-02-05 01:04:05      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:

开发提出须要从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-

Greenplum同步到Oracle

标签:

原文地址:http://www.cnblogs.com/mengfanrong/p/5182270.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!