Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # install the extension
- CREATE EXTENSION postgres_fdw;
- # create a foreign server
- CREATE SERVER foreign_server
- FOREIGN DATA WRAPPER postgres_fdw
- OPTIONS (host='192.83.123.89', port='5432', dbname='foreign_db');
- # A user mapping is needed to identify the role that will be used on the remote server:
- CREATE USER MAPPING FOR local_user
- SERVER foreign_server
- OPTIONS (user='foreign_user', password='password');
- # create a foreign table
- CREATE FOREIGN TABLE foreign_table (
- id serial NOT NULL,
- data text)
- SERVER foreign_server
- OPTIONS (schema_name 'some_schema', table_name 'some_table');
- INSERT INTO foreign_table VALUES(123, 'hello world');
- SELECT * FROM foreign_table;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement