postgres foreign tables data dblink postgres_fdw file_fdw - ghdrako/doc_snipets GitHub Wiki

only postgres_fdw and file_fdw are part of the official Postgres distribution.

List

\detr
select * from information_schema.foreign_tables;
select table_name,table_type from information_schema.tables where table_type='FOREIGN TABLE' and table_schema='public';

dblink

CREATE EXTENSION DBLINK;

INSERT INTO
<SCHEMA_NAME>.<TABLE_NAME_1>
SELECT *
FROM
DBLINK(
'HOST=<IP-ADDRESS> USER=<USERNAME> PASSWORD=<PASSWORD> DBNAME=<DATABASE>',
'SELECT * FROM <SCHEMA_NAME>.<TABLE_NAME_2>')
AS <TABLE_NAME>
(
<COLUMN_1> <DATATYPE_1>,
<COLUMN_1> <DATATYPE_2>,
<COLUMN_1> <DATATYPE_3>
);
⚠️ **GitHub.com Fallback** ⚠️