IMPORT FOREIGN SCHEMA
A DDL command for importing table definitions from a foreign server
IMPORT FOREIGN SCHEMA
is a DDL command dor importing foreign table (and view) definitions from a foreign server.
IMPORT FOREIGN SCHEMA
was added in PostgreSQL 9.5.
Implementation
The implementation of IMPORT FOREIGN SCHEMA
is very much dependent on the individual foreign data wrapper. In particular the settings available via the OPTIONS
parameter are specific to each foreign data wrapper (FDW).
Documentation for IMPORT FOREIGN SCHEMA
as provided by various FDWs:
- postgres_fdw: Importing Options
- db2_fdw: Support for IMPORT FOREIGN SCHEMA
- firebird_fdw: IMPORT FOREIGN SCHEMA options
- oracle_fdw: Support for IMPORT FOREIGN SCHEMA
Note that some FDWs (e.g. file_fdw
) do not support IMPORT FOREIGN SCHEMA
, as there is no underlying schema which can be imported.
Change history
IMPORT FOREIGN SCHEMA
has not been modified since it was introduced in PostgreSQL 9.5.
- PostgreSQL 9.5
- added (initial commit 59efda3e)
Examples
With postgres_fdw:
IMPORT FOREIGN SCHEMA public LIMIT TO (sometable) FROM SERVER pg_remote_server INTO public; IMPORT FOREIGN SCHEMA public EXCEPT (othertable, thattable) FROM SERVER pg_remote_server INTO public; IMPORT FOREIGN SCHEMA public EXCEPT (othertable, thattable) FROM SERVER pg_remote_server INTO public OPTIONS (import_not_null 'false');
References
- PostgreSQL documentation: IMPORT FOREIGN SCHEMA
Useful links
- PostgreSQL 9.5: IMPORT FOREIGN SCHEMA - May 2015 blog article by 2ndQuadrant