IMPORT FOREIGN SCHEMA

Synopsis

Use the IMPORT FOREIGN SCHEMA command to create foreign tables that represent tables in a foreign schema on a foreign server. The newly created foreign tables are owned by the user who issued the command. By default, all the tables in the foreign schema are imported. However, the user can specify which tables to import using the LIMIT TO and EXCEPT clauses. To use this command, the user must have USAGE privileges on the foreign server, and CREATE privileges on the target schema.

Syntax

import_foreign_schema ::= IMPORT FOREIGN SCHEMA remote_schema 
                          [ { LIMIT TO | EXCEPT } ( table_name [ ... ] 
                            ) ] FROM SERVER server_name INTO 
                          local_schema [ OPTIONS ( fdw_options ) ]

import_foreign_schema

IMPORTFOREIGNSCHEMAremote_schemaLIMITTOEXCEPT(table_name)FROMSERVERserver_nameINTOlocal_schemaOPTIONS(fdw_options)

Semantics

Create foreign tables (in local_schema) that represent tables in a foreign schema named remote_schema located on a foreign server named server_name.

LIMIT TO

The LIMIT TO clause can be optionally used to specify which tables to import. All other tables will be ignored.

EXCEPT

The EXCEPT clause can be optionally used to specify which tables to not import. All other tables will be ignored.

See also