[pg93@redhatB ~]$ psql -h 127.0.0.1 psql (9.3.0) Type "help"for help. postgres=# /c francs You are now connected to database "francs" as user "postgres". francs=# create extension mongo_fdw ; CREATE EXTENSION
创建 FOREIGN SERVER
1 2 3 4 5
francs=# CREATE SERVER mongo_server FOREIGN DATA WRAPPER mongo_fdw OPTIONS (address '127.0.0.1', port '27018'); CREATE SERVER francs=# grant usage on FOREIGN server mongo_server to francs; GRANT
创建外部表
1 2 3 4 5 6 7 8
CREATE FOREIGN TABLE ft_test_fdw ( _id NAME, id int4, nametext ) SERVER mongo_server OPTIONS (database'test', collection 'test_fdw');
Mongo_fdw 测试
1 2 3 4 5 6 7 8 9
francs=> analyze ft_test_fdw; ANALYZE francs=> select * from ft_test_fdw ; _id | id | name --------------------------+----+-------- 534ded23453824de92745949 | 1 | francs 534ded2c453824de9274594a | 2 | zhou (2 rows)