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