2 .\" Title: IMPORT FOREIGN SCHEMA
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "IMPORT FOREIGN SCHEMA" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 IMPORT_FOREIGN_SCHEMA \- import table definitions from a foreign server
35 IMPORT FOREIGN SCHEMA \fIremote_schema\fR
36 [ { LIMIT TO | EXCEPT } ( \fItable_name\fR [, \&.\&.\&.] ) ]
37 FROM SERVER \fIserver_name\fR
38 INTO \fIlocal_schema\fR
39 [ OPTIONS ( \fIoption\fR \*(Aq\fIvalue\fR\*(Aq [, \&.\&.\&. ] ) ]
43 \fBIMPORT FOREIGN SCHEMA\fR
44 creates foreign tables that represent tables existing on a foreign server\&. The new foreign tables will be owned by the user issuing the command and are created with the correct column definitions and options to match the remote tables\&.
46 By default, all tables and views existing in a particular schema on the foreign server are imported\&. Optionally, the list of tables can be limited to a specified subset, or specific tables can be excluded\&. The new foreign tables are all created in the target schema, which must already exist\&.
49 \fBIMPORT FOREIGN SCHEMA\fR, the user must have
51 privilege on the foreign server, as well as
53 privilege on the target schema\&.
58 The remote schema to import from\&. The specific meaning of a remote schema depends on the foreign data wrapper in use\&.
61 LIMIT TO ( \fItable_name\fR [, \&.\&.\&.] )
63 Import only foreign tables matching one of the given table names\&. Other tables existing in the foreign schema will be ignored\&.
66 EXCEPT ( \fItable_name\fR [, \&.\&.\&.] )
68 Exclude specified foreign tables from the import\&. All tables existing in the foreign schema will be imported except the ones listed here\&.
73 The foreign server to import from\&.
78 The schema in which the imported foreign tables will be created\&.
81 OPTIONS ( \fIoption\fR \*(Aq\fIvalue\fR\*(Aq [, \&.\&.\&.] )
83 Options to be used during the import\&. The allowed option names and values are specific to each foreign data wrapper\&.
87 Import table definitions from a remote schema
90 film_server, creating the foreign tables in local schema
97 IMPORT FOREIGN SCHEMA foreign_films
98 FROM SERVER film_server INTO films;
104 As above, but import only the two tables
114 IMPORT FOREIGN SCHEMA foreign_films LIMIT TO (actors, directors)
115 FROM SERVER film_server INTO films;
123 \fBIMPORT FOREIGN SCHEMA\fR
124 command conforms to the
126 standard, except that the
132 CREATE FOREIGN TABLE (\fBCREATE_FOREIGN_TABLE\fR(7)), CREATE SERVER (\fBCREATE_SERVER\fR(7))