doc: ALTER DEFAULT PRIVILEGES does not affect inherited roles
[pgsql.git] / doc / src / sgml / ref / create_user_mapping.sgml
blob55debd54012df27e9e410684f3c77c4a010f0dc8
1 <!--
2 doc/src/sgml/ref/create_user_mapping.sgml
3 PostgreSQL documentation
4 -->
6 <refentry id="sql-createusermapping">
7 <indexterm zone="sql-createusermapping">
8 <primary>CREATE USER MAPPING</primary>
9 </indexterm>
11 <refmeta>
12 <refentrytitle>CREATE USER MAPPING</refentrytitle>
13 <manvolnum>7</manvolnum>
14 <refmiscinfo>SQL - Language Statements</refmiscinfo>
15 </refmeta>
17 <refnamediv>
18 <refname>CREATE USER MAPPING</refname>
19 <refpurpose>define a new mapping of a user to a foreign server</refpurpose>
20 </refnamediv>
22 <refsynopsisdiv>
23 <synopsis>
24 CREATE USER MAPPING [ IF NOT EXISTS ] FOR { <replaceable class="parameter">user_name</replaceable> | USER | CURRENT_ROLE | CURRENT_USER | PUBLIC }
25 SERVER <replaceable class="parameter">server_name</replaceable>
26 [ OPTIONS ( <replaceable class="parameter">option</replaceable> '<replaceable class="parameter">value</replaceable>' [ , ... ] ) ]
27 </synopsis>
28 </refsynopsisdiv>
30 <refsect1>
31 <title>Description</title>
33 <para>
34 <command>CREATE USER MAPPING</command> defines a mapping of a user
35 to a foreign server. A user mapping typically encapsulates
36 connection information that a foreign-data wrapper uses together
37 with the information encapsulated by a foreign server to access an
38 external data resource.
39 </para>
41 <para>
42 The owner of a foreign server can create user mappings for that
43 server for any user. Also, a user can create a user mapping for
44 their own user name if <literal>USAGE</literal> privilege on the server has
45 been granted to the user.
46 </para>
47 </refsect1>
49 <refsect1>
50 <title>Parameters</title>
52 <variablelist>
53 <varlistentry>
54 <term><literal>IF NOT EXISTS</literal></term>
55 <listitem>
56 <para>
57 Do not throw an error if a mapping of the given user to the given foreign
58 server already exists. A notice is issued in this case. Note that there
59 is no guarantee that the existing user mapping is anything like the one
60 that would have been created.
61 </para>
62 </listitem>
63 </varlistentry>
65 <varlistentry>
66 <term><replaceable class="parameter">user_name</replaceable></term>
67 <listitem>
68 <para>
69 The name of an existing user that is mapped to foreign server.
70 <literal>CURRENT_ROLE</literal>, <literal>CURRENT_USER</literal>, and <literal>USER</literal> match the name of
71 the current user. When <literal>PUBLIC</literal> is specified, a
72 so-called public mapping is created that is used when no
73 user-specific mapping is applicable.
74 </para>
75 </listitem>
76 </varlistentry>
78 <varlistentry>
79 <term><replaceable class="parameter">server_name</replaceable></term>
80 <listitem>
81 <para>
82 The name of an existing server for which the user mapping is
83 to be created.
84 </para>
85 </listitem>
86 </varlistentry>
88 <varlistentry>
89 <term><literal>OPTIONS ( <replaceable class="parameter">option</replaceable> '<replaceable class="parameter">value</replaceable>' [, ... ] )</literal></term>
90 <listitem>
91 <para>
92 This clause specifies the options of the user mapping. The
93 options typically define the actual user name and password of
94 the mapping. Option names must be unique. The allowed option
95 names and values are specific to the server's foreign-data wrapper.
96 </para>
97 </listitem>
98 </varlistentry>
99 </variablelist>
100 </refsect1>
102 <refsect1>
103 <title>Examples</title>
105 <para>
106 Create a user mapping for user <literal>bob</literal>, server <literal>foo</literal>:
107 <programlisting>
108 CREATE USER MAPPING FOR bob SERVER foo OPTIONS (user 'bob', password 'secret');
109 </programlisting></para>
111 </refsect1>
113 <refsect1>
114 <title>Compatibility</title>
116 <para>
117 <command>CREATE USER MAPPING</command> conforms to ISO/IEC 9075-9 (SQL/MED).
118 </para>
119 </refsect1>
121 <refsect1>
122 <title>See Also</title>
124 <simplelist type="inline">
125 <member><xref linkend="sql-alterusermapping"/></member>
126 <member><xref linkend="sql-dropusermapping"/></member>
127 <member><xref linkend="sql-createforeigndatawrapper"/></member>
128 <member><xref linkend="sql-createserver"/></member>
129 </simplelist>
130 </refsect1>
132 </refentry>