aboutsummaryrefslogtreecommitdiff
path: root/doc/src/sgml/ref/alter_user.sgml
blob: 811905787651f71456c9ec1ea0a7ad5011220a70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_user.sgml,v 1.18 2001/12/08 03:24:33 thomas Exp $
PostgreSQL documentation
-->

<refentry id="SQL-ALTERUSER">
 <refmeta>
  <refentrytitle id="sql-alteruser-title">
   ALTER USER
  </refentrytitle>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>
 <refnamediv>
  <refname>
   ALTER USER
  </refname>
  <refpurpose>
   change a database user account
  </refpurpose>
 </refnamediv>
 <refsynopsisdiv>
  <refsynopsisdivinfo>
   <date>2001-07-10</date>
  </refsynopsisdivinfo>
  <synopsis>
ALTER USER <replaceable class="PARAMETER">username</replaceable> [ [ WITH ] <replaceable class="PARAMETER">option</replaceable> [ ... ] ]

where <replaceable class="PARAMETER">option</replaceable> can be:

	  [ ENCRYPTED | UNENCRYPTED ] PASSWORD '<replaceable class="PARAMETER">password</replaceable>' 
        | CREATEDB | NOCREATEDB
        | CREATEUSER | NOCREATEUSER 
        | VALID UNTIL '<replaceable class="PARAMETER">abstime</replaceable>'
  </synopsis>

  <refsect2 id="R2-SQL-ALTERUSER-1">
   <refsect2info>
    <date>1998-09-08</date>
   </refsect2info>
   <title>
    Inputs
   </title>

   <para>
    <variablelist>
     <varlistentry>
      <term><replaceable class="PARAMETER">username</replaceable></term>
      <listitem>
       <para>
	The name of the user whose details are to be altered.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="PARAMETER">password</replaceable></term>
      <listitem>
       <para>
	The new password to be used for this account.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term>ENCRYPTED</term>
      <term>UNENCRYPTED</term>
      <listitem>
       <para> 
	These keywords control whether the
	password is stored encrypted in <literal>pg_shadow</>.  (See
	<xref linkend="SQL-CREATEUSER" endterm="SQL-CREATEUSER-title">
	for more information about this choice.)
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term>CREATEDB</term>
      <term>NOCREATEDB</term>
      <listitem>
       <para> 
	These clauses define a user's ability to create databases.
	If CREATEDB is specified, the user being defined will
	be allowed to create his own databases. Using NOCREATEDB
	will deny a user the ability to create databases.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term>CREATEUSER</term>
      <term>NOCREATEUSER</term>
      <listitem>
       <para>
	These clauses determine whether a user will be permitted to
	create new users himself. This option will also make the user
        a superuser who can override all access restrictions.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="PARAMETER">abstime</replaceable></term>
      <listitem>
       <para>
	The date (and, optionally, the time)
	at which this user's password is to expire.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
  </refsect2>
    
  <refsect2 id="R2-SQL-ALTERUSER-2">
   <refsect2info>
    <date>1998-09-08</date>
   </refsect2info>
   <title>
    Outputs
   </title>
   <para>
    <variablelist>
     <varlistentry>
      <term><computeroutput>ALTER USER</computeroutput></term>
      <listitem>
       <para>
	Message returned if the alteration was successful.
       </para>
      </listitem>
     </varlistentry>
     
     <varlistentry>
      <term><computeroutput>
ERROR:  ALTER USER: user "username" does not exist
       </computeroutput></term>
      <listitem>
       <para>
	Error message returned if the specified user is not known to
	the database.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
  </refsect2>
 </refsynopsisdiv>

 <refsect1 id="R1-SQL-ALTERUSER-1">
  <refsect1info>
   <date>1998-09-08</date>
  </refsect1info>
  <title>
   Description
  </title>
  <para>
   <command>ALTER USER</command> is used to change the attributes of a user's
   <productname>PostgreSQL</productname> account.  Attributes not mentioned
   in the command retain their previous settings.
  </para>
  <para>
   Only a database superuser
   can change privileges and password expiration with this command. Ordinary
   users can only change their own password.
  </para>
  <para>
   <command>ALTER USER</command> cannot change a user's group memberships.
   Use <xref linkend="SQL-ALTERGROUP" endterm="SQL-ALTERGROUP-title">
   to do that.
  </para>
  <para>
   Use <xref linkend="SQL-CREATEUSER" endterm="SQL-CREATEUSER-title">
   to create a new user and <xref linkend="SQL-DROPUSER"
   endterm="SQL-DROPUSER-title"> to remove a user.
  </para>
 </refsect1>

 <refsect1 id="R1-SQL-ALTERUSER-2">
  <title>
   Usage
  </title>
  <para>
   Change a user password:

<programlisting>
ALTER USER davide WITH PASSWORD 'hu8jmn3';
</programlisting>

   Change a user's valid until date:

<programlisting>
ALTER USER manuel VALID UNTIL 'Jan 31 2030';
</programlisting>

   Change a user's valid until date, specifying that his
   authorization should expire at midday on 4th May 1998 using
   the time zone which is one hour ahead of UTC:
<programlisting>
ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1';
</programlisting>

   Give a user the ability to create other users and new databases:

<programlisting>
ALTER USER miriam CREATEUSER CREATEDB;
</programlisting>

  </para>
 </refsect1>

 <refsect1 id="R1-SQL-ALTERUSER-3">
  <title>
   Compatibility
  </title>
    
  <refsect2 id="R2-SQL-ALTERUSER-4">
   <refsect2info>
    <date>1998-09-08</date>
   </refsect2info>
   <title>
    SQL92
   </title>
   <para>
    There is no <command>ALTER USER</command> statement in
    <acronym>SQL92</acronym>.
    The standard leaves
    the definition of users to the implementation.
   </para>
  </refsect2>
 </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->