Last active
May 27, 2022 05:21
-
-
Save RohanM/be489e29cb5dc9dc4998f70369b665d0 to your computer and use it in GitHub Desktop.
Configuring access to multiple postgres databases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- For more see: https://www.compose.com/articles/cross-database-querying-in-compose-postgresql/ | |
-- From client database | |
CREATE EXTENSION postgres_fdw; | |
CREATE SERVER my_server FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'localhost', dbname 'other_db_name', port '5432'); | |
CREATE USER MAPPING FOR my_user SERVER my_server OPTIONS (user 'my_user'); | |
CREATE SCHEMA my_foreign_schema; | |
IMPORT FOREIGN SCHEMA public LIMIT TO (table1, table2, table3) FROM SERVER my_server INTO my_schema; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment