2 $PostgreSQL: pgsql/doc/src/sgml/ref/alter_role.sgml,v 1.2 2005/07/31 17:19:17 tgl Exp $
3 PostgreSQL documentation
6 <refentry id="SQL-ALTERROLE">
8 <refentrytitle id="sql-alterrole-title">ALTER ROLE</refentrytitle>
9 <refmiscinfo>SQL - Language Statements</refmiscinfo>
13 <refname>ALTER ROLE</refname>
14 <refpurpose>change a database role</refpurpose>
17 <indexterm zone="sql-alterrole">
18 <primary>ALTER ROLE</primary>
23 ALTER ROLE <replaceable class="PARAMETER">name</replaceable> [ [ WITH ] <replaceable class="PARAMETER">option</replaceable> [ ... ] ]
25 where <replaceable class="PARAMETER">option</replaceable> can be:
27 SUPERUSER | NOSUPERUSER
28 | CREATEDB | NOCREATEDB
29 | CREATEROLE | NOCREATEROLE
30 | CREATEUSER | NOCREATEUSER
33 | CONNECTION LIMIT <replaceable class="PARAMETER">connlimit</replaceable>
34 | [ ENCRYPTED | UNENCRYPTED ] PASSWORD '<replaceable class="PARAMETER">password</replaceable>'
35 | VALID UNTIL '<replaceable class="PARAMETER">timestamp</replaceable>'
37 ALTER ROLE <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable>newname</replaceable>
39 ALTER ROLE <replaceable class="PARAMETER">name</replaceable> SET <replaceable>parameter</replaceable> { TO | = } { <replaceable>value</replaceable> | DEFAULT }
40 ALTER ROLE <replaceable class="PARAMETER">name</replaceable> RESET <replaceable>parameter</replaceable>
45 <title>Description</title>
48 <command>ALTER ROLE</command> changes the attributes of a
49 <productname>PostgreSQL</productname> role.
53 The first variant of this command listed in the synopsis can change
54 many of the role attributes that can be specified in
55 <xref linkend="sql-createrole" endterm="sql-createrole-title">,
56 which see for details. (All the possible attributes are covered,
57 except that there are no options for adding or removing memberships; use
58 <xref linkend="SQL-GRANT" endterm="SQL-GRANT-title"> and
59 <xref linkend="SQL-REVOKE" endterm="SQL-REVOKE-title"> for that.)
60 Attributes not mentioned in the command retain their previous settings.
61 Database superusers can change any of these settings for any role.
62 Roles having <literal>CREATEROLE</> privilege can change any of these
63 settings, but only for non-superuser roles.
64 Ordinary roles can only change their own password.
68 The second variant changes the name of the role.
69 Database superusers can rename any role.
70 Roles having <literal>CREATEROLE</> privilege can rename non-superuser
72 The current session user cannot be renamed.
73 (Connect as a different user if you need to do that.)
74 Because <literal>MD5</>-encrypted passwords use the role name as
75 cryptographic salt, renaming a role clears its password if the
76 password is <literal>MD5</>-encrypted.
80 The third and the fourth variant change a role's session default for
81 a specified configuration variable. Whenever the role subsequently
82 starts a new session, the specified value becomes the session default,
83 overriding whatever setting is present in <filename>postgresql.conf</>
84 or has been received from the <command>postmaster</command> command line.
85 (For a role without <literal>LOGIN</> privilege, session defaults have
87 Ordinary roles can change their own session defaults.
88 Superusers can change anyone's session defaults.
89 Roles having <literal>CREATEROLE</> privilege can change defaults for
91 Certain variables cannot be set this way, or can only be
92 set if a superuser issues the command.
97 <title>Parameters</title>
101 <term><replaceable class="PARAMETER">name</replaceable></term>
104 The name of the role whose attributes are to be altered.
110 <term><literal>SUPERUSER</literal></term>
111 <term><literal>NOSUPERUSER</literal></term>
112 <term><literal>CREATEDB</></term>
113 <term><literal>NOCREATEDB</></term>
114 <term><literal>CREATEROLE</literal></term>
115 <term><literal>NOCREATEROLE</literal></term>
116 <term><literal>CREATEUSER</literal></term>
117 <term><literal>NOCREATEUSER</literal></term>
118 <term><literal>INHERIT</literal></term>
119 <term><literal>NOINHERIT</literal></term>
120 <term><literal>LOGIN</literal></term>
121 <term><literal>NOLOGIN</literal></term>
122 <term><literal>CONNECTION LIMIT</literal> <replaceable class="parameter">connlimit</replaceable></term>
123 <term><literal>PASSWORD</> <replaceable class="parameter">password</replaceable></term>
124 <term><literal>ENCRYPTED</></term>
125 <term><literal>UNENCRYPTED</></term>
126 <term><literal>VALID UNTIL</literal> '<replaceable class="parameter">timestamp</replaceable>'</term>
129 These clauses alter attributes originally set by
130 <xref linkend="SQL-CREATEROLE" endterm="SQL-CREATEROLE-title">,
131 which see for more information.
137 <term><replaceable>newname</replaceable></term>
140 The new name of the role.
146 <term><replaceable>parameter</replaceable></term>
147 <term><replaceable>value</replaceable></term>
150 Set this role's session default for the specified configuration
151 parameter to the given value. If
152 <replaceable>value</replaceable> is <literal>DEFAULT</literal>
153 or, equivalently, <literal>RESET</literal> is used, the
154 role-specific variable setting is removed, so the role will
155 inherit the system-wide default setting in new sessions. Use
156 <literal>RESET ALL</literal> to clear all role-specific settings.
160 See <xref linkend="sql-set" endterm="sql-set-title"> and <xref
161 linkend="runtime-config"> for more information about allowed
162 parameter names and values.
173 Use <xref linkend="SQL-CREATEROLE" endterm="SQL-CREATEROLE-title">
174 to add new roles, and <xref linkend="SQL-DROPROLE"
175 endterm="SQL-DROPROLE-title"> to remove a role.
179 <command>ALTER ROLE</command> cannot change a role's memberships.
180 Use <xref linkend="SQL-GRANT" endterm="SQL-GRANT-title"> and
181 <xref linkend="SQL-REVOKE" endterm="SQL-REVOKE-title">
186 It is also possible to tie a
187 session default to a specific database rather than to a role; see
188 <xref linkend="sql-alterdatabase" endterm="sql-alterdatabase-title">.
189 Role-specific settings override database-specific
190 ones if there is a conflict.
195 <title>Examples</title>
198 Change a role's password:
201 ALTER ROLE davide WITH PASSWORD 'hu8jmn3';
206 Change a password expiration date, specifying that the password
207 should expire at midday on 4th May 2015 using
208 the time zone which is one hour ahead of <acronym>UTC</>:
210 ALTER ROLE chris VALID UNTIL 'May 4 12:00:00 2015 +1';
215 Make a password valid forever:
217 ALTER ROLE fred VALID UNTIL 'infinity';
222 Give a role the ability to create other roles and new databases:
225 ALTER ROLE miriam CREATEROLE CREATEDB;
230 Give a role a non-default setting of the
231 <xref linkend="guc-maintenance-work-mem"> parameter:
234 ALTER ROLE worker_bee SET maintenance_work_mem = 100000;
240 <title>Compatibility</title>
243 The <command>ALTER ROLE</command> statement is a
244 <productname>PostgreSQL</productname> extension.
249 <title>See Also</title>
251 <simplelist type="inline">
252 <member><xref linkend="sql-createrole" endterm="sql-createrole-title"></member>
253 <member><xref linkend="sql-droprole" endterm="sql-droprole-title"></member>
254 <member><xref linkend="sql-set" endterm="sql-set-title"></member>
259 <!-- Keep this comment at the end of the file
264 sgml-minimize-attributes:nil
265 sgml-always-quote-attributes:t
268 sgml-parent-document:nil
269 sgml-default-dtd-file:"../reference.ced"
270 sgml-exposed-tags:nil
271 sgml-local-catalogs:"/usr/lib/sgml/catalog"
272 sgml-local-ecat-files:nil