postgres_fdw †
- Foreign Data Wrapperのpostgres実装の1つ。
- PostgresSQLデータベースから,別のPostgresSQLデータベースのテーブルにアクセスすることができる。
設定・使用方法 †
CREATE EXTENSION postgres_fdw;
CREATE SERVER postgres_server FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host 'localhost', dbname 'test', port '5434');
CREATE USER MAPPING FOR public SERVER app1
OPTIONS (USER 'postgres', password '');
CREATE FOREIGN TABLE fs_warehouse (
id INT,
name text
) SERVER postgres_server
OPTIONS (TABLE_NAME 'fs_warehouse');
SELECT * FROM fs_warehouse;
-- DROP FOREIGN TABLE fs_warehouse;
-- DROP USER MAPPING FOR public SERVER postgres_server;
-- DROP SERVER postgres_server CASCADE;
参考リンク †