Skip to content

Instantly share code, notes, and snippets.

@crojasaragonez
Created May 8, 2020 16:07
Show Gist options
  • Save crojasaragonez/877bd88027484aa1b342df005ae4c8f1 to your computer and use it in GitHub Desktop.
Save crojasaragonez/877bd88027484aa1b342df005ae4c8f1 to your computer and use it in GitHub Desktop.
describes how to configure a foreign table in postgres
create extension postgres_fdw;
CREATE SERVER postgres_2
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (dbname 'db_2', host '172.17.0.4', port '5432');
CREATE USER MAPPING FOR CURRENT_USER
SERVER postgres_2
OPTIONS (user 'usr', password 'pwd');
IMPORT FOREIGN SCHEMA "public" limit to (table_name) FROM SERVER postgres_2 INTO public;
select * from table_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment