Connecting to remote servers using postgres_fdw

Data is not always in one location only. More often than not, data is spread all over the infrastructure and it can happen that data residing in various places has to be integrated. The solution to the problem is a foreign data wrapper as defined by the SQL/MED standard.

In this section, the postgres_fdw extension will be discussed. It is a module that allows you to dynamically fetch data from a PostgreSQL data source. The first thing is to deploy the foreign data wrapper:

test=# \h CREATE FOREIGN DATA WRAPPER Command:     CREATE FOREIGN DATA WRAPPER Description: define a new foreign-data wrapper Syntax: CREATE FOREIGN DATA WRAPPER name     [ HANDLER handler_function | NO HANDLER ]  [ VALIDATOR validator_function ...

Get Mastering PostgreSQL 9.6 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.