Greenplum同步到Oracle指令碼

來源:互聯網
上載者:User

Greenplum同步到Oracle指令碼

開發提出需要從Greenplum同步到Oracle的解決方案,寫了個指令碼用於定時調度處理。

Linux-6-64下安裝Oracle 12C筆記

在CentOS 6.4下安裝Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虛擬機器中安裝步驟

Debian 下 安裝 Oracle 11g XE R2

指令碼如下:

#!/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-

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.