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

NAME

6       ALTER_ROLE - change a database role
7

SYNOPSIS

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

DESCRIPTION

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

PARAMETERS

82       name
83           The name of the role whose attributes are to be altered.
84
85       CURRENT_USER
86           Alter the current user instead of an explicitly identified role.
87
88       SESSION_USER
89           Alter the current session user instead of an explicitly identified
90           role.
91
92       SUPERUSER
93       NOSUPERUSER
94       CREATEDB
95       NOCREATEDB
96       CREATEROLE
97       NOCREATEROLE
98       INHERIT
99       NOINHERIT
100       LOGIN
101       NOLOGIN
102       REPLICATION
103       NOREPLICATION
104       BYPASSRLS
105       NOBYPASSRLS
106       CONNECTION LIMIT connlimit
107       [ ENCRYPTED ] PASSWORD 'password'
108       PASSWORD NULL
109       VALID UNTIL 'timestamp'
110           These clauses alter attributes originally set by CREATE ROLE
111           (CREATE_ROLE(7)). For more information, see the CREATE ROLE
112           reference page.
113
114       new_name
115           The new name of the role.
116
117       database_name
118           The name of the database the configuration variable should be set
119           in.
120
121       configuration_parameter
122       value
123           Set this role's session default for the specified configuration
124           parameter to the given value. If value is DEFAULT or, equivalently,
125           RESET is used, the role-specific variable setting is removed, so
126           the role will inherit the system-wide default setting in new
127           sessions. Use RESET ALL to clear all role-specific settings.  SET
128           FROM CURRENT saves the session's current value of the parameter as
129           the role-specific value. If IN DATABASE is specified, the
130           configuration parameter is set or removed for the given role and
131           database only.
132
133           Role-specific variable settings take effect only at login; SET ROLE
134           (SET_ROLE(7)) and SET SESSION AUTHORIZATION
135           (SET_SESSION_AUTHORIZATION(7)) do not process role-specific
136           variable settings.
137
138           See SET(7) and Chapter 19 for more information about allowed
139           parameter names and values.
140

NOTES

142       Use CREATE ROLE (CREATE_ROLE(7)) to add new roles, and DROP ROLE
143       (DROP_ROLE(7)) to remove a role.
144
145       ALTER ROLE cannot change a role's memberships. Use GRANT(7) and
146       REVOKE(7) to do that.
147
148       Caution must be exercised when specifying an unencrypted password with
149       this command. The password will be transmitted to the server in
150       cleartext, and it might also be logged in the client's command history
151       or the server log.  psql(1) contains a command \password that can be
152       used to change a role's password without exposing the cleartext
153       password.
154
155       It is also possible to tie a session default to a specific database
156       rather than to a role; see ALTER DATABASE (ALTER_DATABASE(7)). If there
157       is a conflict, database-role-specific settings override role-specific
158       ones, which in turn override database-specific ones.
159

EXAMPLES

161       Change a role's password:
162
163           ALTER ROLE davide WITH PASSWORD 'hu8jmn3';
164
165       Remove a role's password:
166
167           ALTER ROLE davide WITH PASSWORD NULL;
168
169       Change a password expiration date, specifying that the password should
170       expire at midday on 4th May 2015 using the time zone which is one hour
171       ahead of UTC:
172
173           ALTER ROLE chris VALID UNTIL 'May 4 12:00:00 2015 +1';
174
175       Make a password valid forever:
176
177           ALTER ROLE fred VALID UNTIL 'infinity';
178
179       Give a role the ability to create other roles and new databases:
180
181           ALTER ROLE miriam CREATEROLE CREATEDB;
182
183       Give a role a non-default setting of the maintenance_work_mem
184       parameter:
185
186           ALTER ROLE worker_bee SET maintenance_work_mem = 100000;
187
188       Give a role a non-default, database-specific setting of the
189       client_min_messages parameter:
190
191           ALTER ROLE fred IN DATABASE devel SET client_min_messages = DEBUG;
192

COMPATIBILITY

194       The ALTER ROLE statement is a PostgreSQL extension.
195

SEE ALSO

197       CREATE ROLE (CREATE_ROLE(7)), DROP ROLE (DROP_ROLE(7)), ALTER DATABASE
198       (ALTER_DATABASE(7)), SET(7)
199
200
201
202PostgreSQL 11.3                      2019                        ALTER ROLE(7)
Impressum