SQL*Plus: Release 10.2.0.5.0 - Production on Thu May 8 15:41:06 2014
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from test;
ID NAME
---------- -----
1 a
2 b
然后在GP中直接查询Oracle的表:
[gpadmin@gtlions181 ~]$ psql gtlions
psql (8.2.15)
Type "help" for help.
gtlions=# drop external table if exists sqlplus_test;
DROP EXTERNAL TABLE
gtlions=# create external web table sqlplus_test(id int,name varchar(5)) execute ‘sqlplus -S gtlions/gtlions@gt10g <<EOF
gtlions‘# set echo OFF;
gtlions‘# set heading OFF;
gtlions‘# set feedback off;
gtlions‘# set linesize 32767;
gtlions‘# set pagesize 0;
gtlions‘# select id||‘‘,‘‘||name from test ;
gtlions‘# exit;
gtlions‘# EOF‘ on master format ‘csv‘ (header);
NOTICE: HEADER means that each one of the data files has a header row.
CREATE EXTERNAL TABLE
gtlions=# select * from sqlplus_test;
id | name
----+------
1 | a
2 | b
(2 rows)