]> begriffs open source - ai-pg/blob - full-docs/man7/IMPORT_FOREIGN_SCHEMA.7
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man7 / IMPORT_FOREIGN_SCHEMA.7
1 '\" t
2 .\"     Title: IMPORT FOREIGN SCHEMA
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
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 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 IMPORT_FOREIGN_SCHEMA \- import table definitions from a foreign server
32 .SH "SYNOPSIS"
33 .sp
34 .nf
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 [, \&.\&.\&. ] ) ]
40 .fi
41 .SH "DESCRIPTION"
42 .PP
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\&.
45 .PP
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\&.
47 .PP
48 To use
49 \fBIMPORT FOREIGN SCHEMA\fR, the user must have
50 USAGE
51 privilege on the foreign server, as well as
52 CREATE
53 privilege on the target schema\&.
54 .SH "PARAMETERS"
55 .PP
56 \fIremote_schema\fR
57 .RS 4
58 The remote schema to import from\&. The specific meaning of a remote schema depends on the foreign data wrapper in use\&.
59 .RE
60 .PP
61 LIMIT TO ( \fItable_name\fR [, \&.\&.\&.] )
62 .RS 4
63 Import only foreign tables matching one of the given table names\&. Other tables existing in the foreign schema will be ignored\&.
64 .RE
65 .PP
66 EXCEPT ( \fItable_name\fR [, \&.\&.\&.] )
67 .RS 4
68 Exclude specified foreign tables from the import\&. All tables existing in the foreign schema will be imported except the ones listed here\&.
69 .RE
70 .PP
71 \fIserver_name\fR
72 .RS 4
73 The foreign server to import from\&.
74 .RE
75 .PP
76 \fIlocal_schema\fR
77 .RS 4
78 The schema in which the imported foreign tables will be created\&.
79 .RE
80 .PP
81 OPTIONS ( \fIoption\fR \*(Aq\fIvalue\fR\*(Aq [, \&.\&.\&.] )
82 .RS 4
83 Options to be used during the import\&. The allowed option names and values are specific to each foreign data wrapper\&.
84 .RE
85 .SH "EXAMPLES"
86 .PP
87 Import table definitions from a remote schema
88 foreign_films
89 on server
90 film_server, creating the foreign tables in local schema
91 films:
92 .sp
93 .if n \{\
94 .RS 4
95 .\}
96 .nf
97 IMPORT FOREIGN SCHEMA foreign_films
98     FROM SERVER film_server INTO films;
99 .fi
100 .if n \{\
101 .RE
102 .\}
103 .PP
104 As above, but import only the two tables
105 actors
106 and
107 directors
108 (if they exist):
109 .sp
110 .if n \{\
111 .RS 4
112 .\}
113 .nf
114 IMPORT FOREIGN SCHEMA foreign_films LIMIT TO (actors, directors)
115     FROM SERVER film_server INTO films;
116 .fi
117 .if n \{\
118 .RE
119 .\}
120 .SH "COMPATIBILITY"
121 .PP
122 The
123 \fBIMPORT FOREIGN SCHEMA\fR
124 command conforms to the
125 SQL
126 standard, except that the
127 OPTIONS
128 clause is a
129 PostgreSQL
130 extension\&.
131 .SH "SEE ALSO"
132 CREATE FOREIGN TABLE (\fBCREATE_FOREIGN_TABLE\fR(7)), CREATE SERVER (\fBCREATE_SERVER\fR(7))