Create extension
CREATE EXTENSION postgres_fdw;
Create server
CREATE SERVER server_name FOREIGN DATA WRAPPER postgres_fdw options(host 'host_addr', port '5432', dbname 'db_name');
Create user mapping
CREATE USER MAPPING FOR postgres SERVER server_name options(user 'username',password 'password');
Import remote schema
IMPORT FOREIGN SCHEMA schema_name LIMIT TO (table1,table2,...) FROM SERVER server_name INTO destination_schema;
\dx list the installed extensions \des List the foreign servers \deu+ List the user mappings
Drop
DROP FOREIGN TABLE table_name; DROP USER MAPPING FOR user_name SERVER server_name; DROP SERVER server_name;