Home Explore Blog CI



postgresql

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

<refentry id="sql-createusermapping">
 <indexterm zone="sql-createusermapping">
  <primary>CREATE USER MAPPING</primary>
 </indexterm>

 <refmeta>
  <refentrytitle>CREATE USER MAPPING</refentrytitle>
  <manvolnum>7</manvolnum>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>CREATE USER MAPPING</refname>
  <refpurpose>define a new mapping of a user to a foreign server</refpurpose>
 </refnamediv>

 <refsynopsisdiv>
<synopsis>
CREATE USER MAPPING [ IF NOT EXISTS ] FOR { <replaceable class="parameter">user_name</replaceable> | USER | CURRENT_ROLE | CURRENT_USER | PUBLIC }
    SERVER <replaceable class="parameter">server_name</replaceable>
    [ OPTIONS ( <replaceable class="parameter">option</replaceable> '<replaceable class="parameter">value</replaceable>' [ , ... ] ) ]
</synopsis>
 </refsynopsisdiv>

 <refsect1>
  <title>Description</title>

  <para>
   <command>CREATE USER MAPPING</command> defines a mapping of a user
   to a foreign server.  A user mapping typically encapsulates
   connection information that a foreign-data wrapper uses together
   with the information encapsulated by a foreign server to access an
   external data resource.
  </para>

  <para>
   The owner of a foreign server can create user mappings for that
   server for any user.  Also, a user can create a user mapping for
   their own user name if <literal>USAGE</literal> privilege on the server has
   been granted to the user.
  </para>
 </refsect1>

 <refsect1>
  <title>Parameters</title>

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

   <varlistentry>
    <term><replaceable class="parameter">user_name</replaceable></term>

Title: CREATE USER MAPPING: Define a New User Mapping to a Foreign Server
Summary
The CREATE USER MAPPING command defines a mapping between a PostgreSQL user and a foreign server, typically encapsulating connection information used by a foreign-data wrapper. The owner of a foreign server can create user mappings for any user, and a user can create a mapping for their own user name if granted USAGE privilege. The IF NOT EXISTS option prevents errors if the mapping already exists, issuing a notice instead.