Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/ref/create_server.sgml`
a30ff777ddf3f21f0546dbd6ba7eacfeb5de07fbfbcca5cf0000000100000db3
 server requires <literal>USAGE</literal> privilege on the
   foreign-data wrapper being used.
  </para>
 </refsect1>

 <refsect1>
  <title>Parameters</title>

  <variablelist>
  <varlistentry>
    <term><literal>IF NOT EXISTS</literal></term>
    <listitem>
     <para>
      Do not throw an error if a server with the same name already exists.
      A notice is issued in this case.  Note that there is no guarantee that
      the existing server is anything like the one that would have been
      created.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">server_name</replaceable></term>
    <listitem>
     <para>
      The name of the foreign server to be created.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">server_type</replaceable></term>
    <listitem>
     <para>
      Optional server type, potentially useful to foreign-data wrappers.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">server_version</replaceable></term>
    <listitem>
     <para>
      Optional server version, potentially useful to foreign-data wrappers.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">fdw_name</replaceable></term>
    <listitem>
     <para>
      The name of the foreign-data wrapper that manages the server.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>OPTIONS ( <replaceable class="parameter">option</replaceable> '<replaceable class="parameter">value</replaceable>' [, ... ] )</literal></term>
    <listitem>
     <para>
      This clause specifies the options for the server.  The options
      typically define the connection details of the server, but the
      actual names and values are dependent on the server's
      foreign-data wrapper.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1>
  <title>Notes</title>

  <para>
   When using the <xref linkend="dblink"/> module,
   a foreign server's name can be used
   as an argument of the <xref linkend="contrib-dblink-connect"/>
   function to indicate the connection parameters.  It is necessary to have
   the <literal>USAGE</literal> privilege on the foreign server to be
   able to use it in this way.
  </para>

  <para>
   If the foreign server supports sort pushdown, it is necessary for it
   to have the same sort ordering as the local server.
  </para>
 </refsect1>

 <refsect1>
  <title>Examples</title>

  <para>
   Create a server <literal>myserver</literal> that uses the
   foreign-data wrapper <literal>postgres_fdw</literal>:
<programlisting>
CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');
</programlisting>
   See <xref linkend="postgres-fdw"/> for more details.
  </para>
 </refsect1>

 <refsect1>
  <title>Compatibility</title>

  <para>
   <command>CREATE SERVER</command> conforms to ISO/IEC 9075-9 (SQL/MED).
  </para>
 </refsect1>

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

  <simplelist type="inline">
   <member><xref linkend="sql-alterserver"/></member>
   <member><xref linkend="sql-dropserver"/></member>
   <member><xref linkend="sql-createforeigndatawrapper"/></member>
   <member><xref linkend="sql-createforeigntable"/></member>
   <member><xref linkend="sql-createusermapping"/></member>
  </simplelist>
 </refsect1>

</refentry>

Title: CREATE SERVER: Parameters, Notes, Examples, and Compatibility
Summary
This section details the parameters for the CREATE SERVER command, including IF NOT EXISTS, server_name, server_type, server_version, fdw_name, and OPTIONS. It also provides notes on using foreign servers with dblink and sort pushdown. An example demonstrates creating a server with postgres_fdw. The command conforms to SQL/MED.