]> begriffs open source - ai-pg/blob - full-docs/html/sql-importforeignschema.html
Include latest toc output
[ai-pg] / full-docs / html / sql-importforeignschema.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>IMPORT FOREIGN SCHEMA</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="sql-grant.html" title="GRANT" /><link rel="next" href="sql-insert.html" title="INSERT" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">IMPORT FOREIGN SCHEMA</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-grant.html" title="GRANT">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-insert.html" title="INSERT">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-IMPORTFOREIGNSCHEMA"><div class="titlepage"></div><a id="id-1.9.3.151.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">IMPORT FOREIGN SCHEMA</span></h2><p>IMPORT FOREIGN SCHEMA — import table definitions from a foreign server</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
3 IMPORT FOREIGN SCHEMA <em class="replaceable"><code>remote_schema</code></em>
4     [ { LIMIT TO | EXCEPT } ( <em class="replaceable"><code>table_name</code></em> [, ...] ) ]
5     FROM SERVER <em class="replaceable"><code>server_name</code></em>
6     INTO <em class="replaceable"><code>local_schema</code></em>
7     [ OPTIONS ( <em class="replaceable"><code>option</code></em> '<em class="replaceable"><code>value</code></em>' [, ... ] ) ]
8 </pre></div><div class="refsect1" id="SQL-IMPORTFOREIGNSCHEMA-DESCRIPTION"><h2>Description</h2><p>
9    <code class="command">IMPORT FOREIGN SCHEMA</code> creates foreign tables that
10    represent tables existing on a foreign server.  The new foreign tables
11    will be owned by the user issuing the command and are created with
12    the correct column definitions and options to match the remote tables.
13   </p><p>
14    By default, all tables and views existing in a particular schema on the
15    foreign server are imported.  Optionally, the list of tables can be limited
16    to a specified subset, or specific tables can be excluded.  The new foreign
17    tables are all created in the target schema, which must already exist.
18   </p><p>
19    To use <code class="command">IMPORT FOREIGN SCHEMA</code>, the user must have
20    <code class="literal">USAGE</code> privilege on the foreign server, as well as
21    <code class="literal">CREATE</code> privilege on the target schema.
22   </p></div><div class="refsect1" id="id-1.9.3.151.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>remote_schema</code></em></span></dt><dd><p>
23       The remote schema to import from. The specific meaning of a remote schema
24       depends on the foreign data wrapper in use.
25      </p></dd><dt><span class="term"><code class="literal">LIMIT TO ( <em class="replaceable"><code>table_name</code></em> [, ...] )</code></span></dt><dd><p>
26       Import only foreign tables matching one of the given table names.
27       Other tables existing in the foreign schema will be ignored.
28      </p></dd><dt><span class="term"><code class="literal">EXCEPT ( <em class="replaceable"><code>table_name</code></em> [, ...] )</code></span></dt><dd><p>
29       Exclude specified foreign tables from the import.  All tables
30       existing in the foreign schema will be imported except the
31       ones listed here.
32      </p></dd><dt><span class="term"><em class="replaceable"><code>server_name</code></em></span></dt><dd><p>
33       The foreign server to import from.
34      </p></dd><dt><span class="term"><em class="replaceable"><code>local_schema</code></em></span></dt><dd><p>
35       The schema in which the imported foreign tables will be created.
36      </p></dd><dt><span class="term"><code class="literal">OPTIONS ( <em class="replaceable"><code>option</code></em> '<em class="replaceable"><code>value</code></em>' [, ...] )</code></span></dt><dd><p>
37       Options to be used during the import.
38       The allowed option names and values are specific to each foreign
39       data wrapper.
40      </p></dd></dl></div></div><div class="refsect1" id="SQL-IMPORTFOREIGNSCHEMA-EXAMPLES"><h2>Examples</h2><p>
41    Import table definitions from a remote schema <code class="structname">foreign_films</code>
42    on server <code class="structname">film_server</code>, creating the foreign tables in
43    local schema <code class="structname">films</code>:
44
45 </p><pre class="programlisting">
46 IMPORT FOREIGN SCHEMA foreign_films
47     FROM SERVER film_server INTO films;
48 </pre><p>
49    </p><p>
50    As above, but import only the two tables <code class="structname">actors</code> and
51    <code class="literal">directors</code> (if they exist):
52
53 </p><pre class="programlisting">
54 IMPORT FOREIGN SCHEMA foreign_films LIMIT TO (actors, directors)
55     FROM SERVER film_server INTO films;
56 </pre></div><div class="refsect1" id="SQL-IMPORTFOREIGNSCHEMA-COMPATIBILITY"><h2>Compatibility</h2><p>
57    The <code class="command">IMPORT FOREIGN SCHEMA</code> command conforms to the
58    <acronym class="acronym">SQL</acronym> standard, except that the <code class="literal">OPTIONS</code>
59    clause is a <span class="productname">PostgreSQL</span> extension.
60   </p></div><div class="refsect1" id="id-1.9.3.151.9"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-createforeigntable.html" title="CREATE FOREIGN TABLE"><span class="refentrytitle">CREATE FOREIGN TABLE</span></a>, <a class="xref" href="sql-createserver.html" title="CREATE SERVER"><span class="refentrytitle">CREATE SERVER</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-grant.html" title="GRANT">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-insert.html" title="INSERT">Next</a></td></tr><tr><td width="40%" align="left" valign="top">GRANT </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> INSERT</td></tr></table></div></body></html>