Created
May 28, 2025 09:23
-
-
Save CHERTS/cccfb79c29c55a94ba0cdfac6a962b94 to your computer and use it in GitHub Desktop.
PostgreSQL FDW Examples
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
CREATE EXTENSION IF NOT EXISTS postgres_fdw; | |
CREATE SERVER IF NOT EXISTS my_server FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host '1.2.3.4', dbname 'my_db', port '5432', sslmode 'disable', connect_timeout '10', application_name 'fdw'); | |
CREATE USER MAPPING IF NOT EXISTS FOR my_user SERVER my_server OPTIONS (user 'my_user', password 'BigPa$$w0rd!'); | |
IMPORT FOREIGN SCHEMA public LIMIT TO (table1,table2) FROM SERVER my_server INTO public; | |
SELECT * FROM table1 LIMIT 10; | |
SELECT * FROM table2 LIMIT 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment