postgres foreign tables data dblink postgres_fdw file_fdw - ghdrako/doc_snipets GitHub Wiki
- https://www.postgresql.org/docs/current/postgres-fdw.html
- https://www.postgresql.org/docs/current/ddl-foreign-data.html
- https://www.postgresql.org/docs/current/sql-createforeigntable.html
- https://wiki.postgresql.org/wiki/Foreign_data_wrappers
- https://github.com/ghdrako/doc_snipets/wiki/postgres-extension-postgres_fdw-file_fdw
- https://www.postgresql.org/docs/current/dblink.html - old replace by postgres-fdw
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';
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>
);