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:

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.

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');

Categories

DDL, Foreign Data Wrapper (FDW), SQL command