Connecting to remote servers using postgres_fdw

Data is not always in just one location. More often than not, data is spread all over the infrastructure, and it may be that data residing in various places has to be integrated.

The solution to this 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 us to dynamically fetch data from a PostgreSQL data source. The first thing we need to do is deploy the foreign data wrapper:

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

Get Mastering PostgreSQL 12 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.