How it works...
We start by connecting to the database where we will be accessing remote data. As our test database is pgbench, this is where the foreign server will reside.
The server creation itself consists of a server name, a foreign-data wrapper, and options for the foreign-data wrapper. For the server name, we used primary_db to keep things simple, but anything relatively descriptive is a good choice.
The CREATE SERVER statement can use several available foreign data wrappers, but to contact a PostgreSQL server, we need postgres_fdw. This data wrapper will accept many standard PostgreSQL connection parameters, including host, dbname, port, and so on.
We only used the dbname and host settings because we don't want to force this server ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access