]> begriffs open source - ai-pg/blob - full-docs/txt/sql-importforeignschema.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / sql-importforeignschema.txt
1
2 IMPORT FOREIGN SCHEMA
3
4    IMPORT FOREIGN SCHEMA — import table definitions from a foreign server
5
6 Synopsis
7
8 IMPORT FOREIGN SCHEMA remote_schema
9     [ { LIMIT TO | EXCEPT } ( table_name [, ...] ) ]
10     FROM SERVER server_name
11     INTO local_schema
12     [ OPTIONS ( option 'value' [, ... ] ) ]
13
14 Description
15
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.
20
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
25    already exist.
26
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.
29
30 Parameters
31
32    remote_schema
33           The remote schema to import from. The specific meaning of a
34           remote schema depends on the foreign data wrapper in use.
35
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
39           ignored.
40
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
44           listed here.
45
46    server_name
47           The foreign server to import from.
48
49    local_schema
50           The schema in which the imported foreign tables will be created.
51
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.
55
56 Examples
57
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;
62
63    As above, but import only the two tables actors and directors (if they
64    exist):
65 IMPORT FOREIGN SCHEMA foreign_films LIMIT TO (actors, directors)
66     FROM SERVER film_server INTO films;
67
68 Compatibility
69
70    The IMPORT FOREIGN SCHEMA command conforms to the SQL standard, except
71    that the OPTIONS clause is a PostgreSQL extension.
72
73 See Also
74
75    CREATE FOREIGN TABLE, CREATE SERVER