Advertisement
Guest User

Untitled

a guest
May 24th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. # install the extension
  2. CREATE EXTENSION postgres_fdw;
  3.  
  4. # create a foreign server
  5. CREATE SERVER foreign_server
  6. FOREIGN DATA WRAPPER postgres_fdw
  7. OPTIONS (host='192.83.123.89', port='5432', dbname='foreign_db');
  8.  
  9. # A user mapping is needed to identify the role that will be used on the remote server:
  10. CREATE USER MAPPING FOR local_user
  11. SERVER foreign_server
  12. OPTIONS (user='foreign_user', password='password');
  13.  
  14. # create a foreign table
  15. CREATE FOREIGN TABLE foreign_table (
  16. id serial NOT NULL,
  17. data text)
  18. SERVER foreign_server
  19. OPTIONS (schema_name 'some_schema', table_name 'some_table');
  20.  
  21. INSERT INTO foreign_table VALUES(123, 'hello world');
  22. SELECT * FROM foreign_table;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement