1ALTER ROLE(7)           PostgreSQL 9.2.24 Documentation          ALTER ROLE(7)
2
3
4

NAME

6       ALTER_ROLE - change a database role
7

SYNOPSIS

9       ALTER ROLE name [ [ WITH ] option [ ... ] ]
10
11       where option can be:
12
13             SUPERUSER | NOSUPERUSER
14           | CREATEDB | NOCREATEDB
15           | CREATEROLE | NOCREATEROLE
16           | CREATEUSER | NOCREATEUSER
17           | INHERIT | NOINHERIT
18           | LOGIN | NOLOGIN
19           | REPLICATION | NOREPLICATION
20           | CONNECTION LIMIT connlimit
21           | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
22           | VALID UNTIL 'timestamp'
23
24       ALTER ROLE name RENAME TO new_name
25
26       ALTER ROLE name [ IN DATABASE database_name ] SET configuration_parameter { TO | = } { value | DEFAULT }
27       ALTER ROLE name [ IN DATABASE database_name ] SET configuration_parameter FROM CURRENT
28       ALTER ROLE name [ IN DATABASE database_name ] RESET configuration_parameter
29       ALTER ROLE name [ IN DATABASE database_name ] RESET ALL
30

DESCRIPTION

32       ALTER ROLE changes the attributes of a PostgreSQL role.
33
34       The first variant of this command listed in the synopsis can change
35       many of the role attributes that can be specified in CREATE ROLE
36       (CREATE_ROLE(7)). (All the possible attributes are covered, except that
37       there are no options for adding or removing memberships; use GRANT(7)
38       and REVOKE(7) for that.) Attributes not mentioned in the command retain
39       their previous settings. Database superusers can change any of these
40       settings for any role. Roles having CREATEROLE privilege can change any
41       of these settings, but only for non-superuser and non-replication
42       roles. Ordinary roles can only change their own password.
43
44       The second variant changes the name of the role. Database superusers
45       can rename any role. Roles having CREATEROLE privilege can rename
46       non-superuser roles. The current session user cannot be renamed.
47       (Connect as a different user if you need to do that.) Because
48       MD5-encrypted passwords use the role name as cryptographic salt,
49       renaming a role clears its password if the password is MD5-encrypted.
50
51       The remaining variants change a role's session default for a
52       configuration variable, either for all databases or, when the IN
53       DATABASE clause is specified, only for sessions in the named database.
54       Whenever the role subsequently starts a new session, the specified
55       value becomes the session default, overriding whatever setting is
56       present in postgresql.conf or has been received from the postgres
57       command line. This only happens at login time; executing SET ROLE
58       (SET_ROLE(7)) or SET SESSION AUTHORIZATION
59       (SET_SESSION_AUTHORIZATION(7)) does not cause new configuration values
60       to be set. Settings set for all databases are overridden by
61       database-specific settings attached to a role. Superusers can change
62       anyone's session defaults. Roles having CREATEROLE privilege can change
63       defaults for non-superuser roles. Ordinary roles can only set defaults
64       for themselves. Certain configuration variables cannot be set this way,
65       or can only be set if a superuser issues the command.
66

PARAMETERS

68       name
69           The name of the role whose attributes are to be altered.
70
71       SUPERUSER, NOSUPERUSER, CREATEDB, NOCREATEDB, CREATEROLE, NOCREATEROLE,
72       CREATEUSER, NOCREATEUSER, INHERIT, NOINHERIT, LOGIN, NOLOGIN,
73       REPLICATION, NOREPLICATION, CONNECTION LIMIT connlimit, PASSWORD
74       password, ENCRYPTED, UNENCRYPTED, VALID UNTIL 'timestamp'
75           These clauses alter attributes originally set by CREATE ROLE
76           (CREATE_ROLE(7)). For more information, see the CREATE ROLE
77           reference page.
78
79       new_name
80           The new name of the role.
81
82       database_name
83           The name of the database the configuration variable should be set
84           in.
85
86       configuration_parameter, value
87           Set this role's session default for the specified configuration
88           parameter to the given value. If value is DEFAULT or, equivalently,
89           RESET is used, the role-specific variable setting is removed, so
90           the role will inherit the system-wide default setting in new
91           sessions. Use RESET ALL to clear all role-specific settings.  SET
92           FROM CURRENT saves the session's current value of the parameter as
93           the role-specific value. If IN DATABASE is specified, the
94           configuration parameter is set or removed for the given role and
95           database only.
96
97           Role-specific variable settings take effect only at login; SET ROLE
98           (SET_ROLE(7)) and SET SESSION AUTHORIZATION
99           (SET_SESSION_AUTHORIZATION(7)) do not process role-specific
100           variable settings.
101
102           See SET(7) and Chapter 18, Server Configuration, in the
103           documentation for more information about allowed parameter names
104           and values.
105

NOTES

107       Use CREATE ROLE (CREATE_ROLE(7)) to add new roles, and DROP ROLE
108       (DROP_ROLE(7)) to remove a role.
109
110       ALTER ROLE cannot change a role's memberships. Use GRANT(7) and
111       REVOKE(7) to do that.
112
113       Caution must be exercised when specifying an unencrypted password with
114       this command. The password will be transmitted to the server in
115       cleartext, and it might also be logged in the client's command history
116       or the server log.  psql(1) contains a command \password that can be
117       used to change a role's password without exposing the cleartext
118       password.
119
120       It is also possible to tie a session default to a specific database
121       rather than to a role; see ALTER DATABASE (ALTER_DATABASE(7)). If there
122       is a conflict, database-role-specific settings override role-specific
123       ones, which in turn override database-specific ones.
124

EXAMPLES

126       Change a role's password:
127
128           ALTER ROLE davide WITH PASSWORD 'hu8jmn3';
129
130       Remove a role's password:
131
132           ALTER ROLE davide WITH PASSWORD NULL;
133
134       Change a password expiration date, specifying that the password should
135       expire at midday on 4th May 2015 using the time zone which is one hour
136       ahead of UTC:
137
138           ALTER ROLE chris VALID UNTIL 'May 4 12:00:00 2015 +1';
139
140       Make a password valid forever:
141
142           ALTER ROLE fred VALID UNTIL 'infinity';
143
144       Give a role the ability to create other roles and new databases:
145
146           ALTER ROLE miriam CREATEROLE CREATEDB;
147
148       Give a role a non-default setting of the maintenance_work_mem
149       parameter:
150
151           ALTER ROLE worker_bee SET maintenance_work_mem = 100000;
152
153       Give a role a non-default, database-specific setting of the
154       client_min_messages parameter:
155
156           ALTER ROLE fred IN DATABASE devel SET client_min_messages = DEBUG;
157

COMPATIBILITY

159       The ALTER ROLE statement is a PostgreSQL extension.
160

SEE ALSO

162       CREATE ROLE (CREATE_ROLE(7)), DROP ROLE (DROP_ROLE(7)), SET(7)
163
164
165
166PostgreSQL 9.2.24                 2017-11-06                     ALTER ROLE(7)
Impressum