Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/ref/import_foreign_schema.sgml`
8f230ccb7adca0caed2eadb627d31b0322ea4d2ce49fdf140000000100000e1a
 subset, or specific tables can be excluded.  The new foreign
   tables are all created in the target schema, which must already exist.
  </para>

  <para>
   To use <command>IMPORT FOREIGN SCHEMA</command>, the user must have
   <literal>USAGE</literal> privilege on the foreign server, as well as
   <literal>CREATE</literal> privilege on the target schema.
  </para>
 </refsect1>

 <refsect1>
  <title>Parameters</title>

  <variablelist>

   <varlistentry>
    <term><replaceable class="parameter">remote_schema</replaceable></term>
    <listitem>
     <para>
      The remote schema to import from. The specific meaning of a remote schema
      depends on the foreign data wrapper in use.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>LIMIT TO ( <replaceable class="parameter">table_name</replaceable> [, ...] )</literal></term>
    <listitem>
     <para>
      Import only foreign tables matching one of the given table names.
      Other tables existing in the foreign schema will be ignored.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>EXCEPT ( <replaceable class="parameter">table_name</replaceable> [, ...] )</literal></term>
    <listitem>
     <para>
      Exclude specified foreign tables from the import.  All tables
      existing in the foreign schema will be imported except the
      ones listed here.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">server_name</replaceable></term>
    <listitem>
     <para>
      The foreign server to import from.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">local_schema</replaceable></term>
    <listitem>
     <para>
      The schema in which the imported foreign tables will be created.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>OPTIONS ( <replaceable class="parameter">option</replaceable> '<replaceable class="parameter">value</replaceable>' [, ...] )</literal></term>
    <listitem>
     <para>
      Options to be used during the import.
      The allowed option names and values are specific to each foreign
      data wrapper.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 id="sql-importforeignschema-examples">
  <title>Examples</title>

  <para>
   Import table definitions from a remote schema <structname>foreign_films</structname>
   on server <structname>film_server</structname>, creating the foreign tables in
   local schema <structname>films</structname>:

<programlisting>
IMPORT FOREIGN SCHEMA foreign_films
    FROM SERVER film_server INTO films;
</programlisting>
   </para>

  <para>
   As above, but import only the two tables <structname>actors</structname> and
   <literal>directors</literal> (if they exist):

<programlisting>
IMPORT FOREIGN SCHEMA foreign_films LIMIT TO (actors, directors)
    FROM SERVER film_server INTO films;
</programlisting></para>
 </refsect1>

 <refsect1 id="sql-importforeignschema-compatibility">
  <title>Compatibility</title>

  <para>
   The <command>IMPORT FOREIGN SCHEMA</command> command conforms to the
   <acronym>SQL</acronym> standard, except that the <literal>OPTIONS</literal>
   clause is a <productname>PostgreSQL</productname> extension.
  </para>

 </refsect1>

 <refsect1>
  <title>See Also</title>

  <simplelist type="inline">
   <member><xref linkend="sql-createforeigntable"/></member>
   <member><xref linkend="sql-createserver"/></member>
  </simplelist>
 </refsect1>
</refentry>

Title: IMPORT FOREIGN SCHEMA - Parameters, Examples, and Compatibility
Summary
This section details the parameters for the IMPORT FOREIGN SCHEMA command, including remote_schema, LIMIT TO, EXCEPT, server_name, local_schema, and OPTIONS. It provides examples of importing table definitions from a remote schema and limiting the import to specific tables. Finally, it notes that the command conforms to the SQL standard, with the exception of the OPTIONS clause, which is a PostgreSQL extension. It also provides links to related commands.