4 IMPORT FOREIGN SCHEMA — import table definitions from a foreign server
8 IMPORT FOREIGN SCHEMA remote_schema
9 [ { LIMIT TO | EXCEPT } ( table_name [, ...] ) ]
10 FROM SERVER server_name
12 [ OPTIONS ( option 'value' [, ... ] ) ]
16 IMPORT FOREIGN SCHEMA creates foreign tables that represent tables
17 existing on a foreign server. The new foreign tables will be owned by
18 the user issuing the command and are created with the correct column
19 definitions and options to match the remote tables.
21 By default, all tables and views existing in a particular schema on the
22 foreign server are imported. Optionally, the list of tables can be
23 limited to a specified subset, or specific tables can be excluded. The
24 new foreign tables are all created in the target schema, which must
27 To use IMPORT FOREIGN SCHEMA, the user must have USAGE privilege on the
28 foreign server, as well as CREATE privilege on the target schema.
33 The remote schema to import from. The specific meaning of a
34 remote schema depends on the foreign data wrapper in use.
36 LIMIT TO ( table_name [, ...] )
37 Import only foreign tables matching one of the given table
38 names. Other tables existing in the foreign schema will be
41 EXCEPT ( table_name [, ...] )
42 Exclude specified foreign tables from the import. All tables
43 existing in the foreign schema will be imported except the ones
47 The foreign server to import from.
50 The schema in which the imported foreign tables will be created.
52 OPTIONS ( option 'value' [, ...] )
53 Options to be used during the import. The allowed option names
54 and values are specific to each foreign data wrapper.
58 Import table definitions from a remote schema foreign_films on server
59 film_server, creating the foreign tables in local schema films:
60 IMPORT FOREIGN SCHEMA foreign_films
61 FROM SERVER film_server INTO films;
63 As above, but import only the two tables actors and directors (if they
65 IMPORT FOREIGN SCHEMA foreign_films LIMIT TO (actors, directors)
66 FROM SERVER film_server INTO films;
70 The IMPORT FOREIGN SCHEMA command conforms to the SQL standard, except
71 that the OPTIONS clause is a PostgreSQL extension.
75 CREATE FOREIGN TABLE, CREATE SERVER