Home Explore Blog CI



postgresql

1st chunk of `doc/src/sgml/ref/import_foreign_schema.sgml`
dc53535af27b935a59dd4ed016a1f2cc0e19ff42e15ee4f10000000100000a38
<!--
doc/src/sgml/ref/import_foreign_schema.sgml
PostgreSQL documentation
-->

<refentry id="sql-importforeignschema">
 <indexterm zone="sql-importforeignschema">
  <primary>IMPORT FOREIGN SCHEMA</primary>
 </indexterm>

 <refmeta>
  <refentrytitle>IMPORT FOREIGN SCHEMA</refentrytitle>
  <manvolnum>7</manvolnum>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>IMPORT FOREIGN SCHEMA</refname>
  <refpurpose>import table definitions from a foreign server</refpurpose>
 </refnamediv>

 <refsynopsisdiv>
<synopsis>
IMPORT FOREIGN SCHEMA <replaceable class="parameter">remote_schema</replaceable>
    [ { LIMIT TO | EXCEPT } ( <replaceable class="parameter">table_name</replaceable> [, ...] ) ]
    FROM SERVER <replaceable class="parameter">server_name</replaceable>
    INTO <replaceable class="parameter">local_schema</replaceable>
    [ OPTIONS ( <replaceable class="parameter">option</replaceable> '<replaceable class="parameter">value</replaceable>' [, ... ] ) ]
</synopsis>
 </refsynopsisdiv>

 <refsect1 id="sql-importforeignschema-description">
  <title>Description</title>

  <para>
   <command>IMPORT FOREIGN SCHEMA</command> 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.
  </para>

  <para>
   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.
  </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

Title: IMPORT FOREIGN SCHEMA
Summary
The IMPORT FOREIGN SCHEMA command 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. By default, all tables and views existing in a particular schema on the foreign server are imported, with the option to limit or exclude specific tables. The new foreign tables are all created in the target schema, which must already exist. The user must have USAGE privilege on the foreign server, as well as CREATE privilege on the target schema to use this command. Parameters include the remote schema to import from and the option to limit the import to specific tables.