1. 如果是源码安装,需要进入源码的contib目录,进行make;make install
2. CREATE EXTENSION postgres_fdw;
3. CREATE SERVER gp_server FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host '10.20.100.60', dbname 'test', port '5432');
其中,host为greenplum的master IP地址
4. CREATE USER MAPPING FOR public SERVER
gp_server
OPTIONS (user 'gpadmin', password '');
填入greenplum的用户名密码
5. create foreign table test_forergn(
"id" int ,
"lo" double precision ,
"pt" timestamp without time zone ,
"name" text
)
server gp_server
OPTIONS (schema_name 'public', table_name 'test_gp');
其中options中的table_name即为greenplum中的表名