ALTER USER modifies the attributes of a database user.
Session parameters modified by ALTER USER apply to a specified user and take effect in the next session.
1 | ALTER USER user_name [ [ WITH ] option [ ... ] ]; |
The option clause is as follows:
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 | { CREATEDB | NOCREATEDB } | { CREATEROLE | NOCREATEROLE } | { INHERIT | NOINHERIT } | { AUDITADMIN | NOAUDITADMIN } | { SYSADMIN | NOSYSADMIN } | { USEFT | NOUSEFT } | { LOGIN | NOLOGIN } | { REPLICATION | NOREPLICATION } | {INDEPENDENT | NOINDEPENDENT} | {VCADMIN | NOVCADMIN} | CONNECTION LIMIT connlimit | [ ENCRYPTED | UNENCRYPTED ] PASSWORD { 'password' | DISABLE } | [ ENCRYPTED | UNENCRYPTED ] IDENTIFIED BY { 'password' [ REPLACE 'old_password' ] | DISABLE } | VALID BEGIN 'timestamp' | VALID UNTIL 'timestamp' | RESOURCE POOL 'respool' | USER GROUP 'groupuser' | PERM SPACE 'spacelimit' | TEMP SPACE 'tmpspacelimit' | SPILL SPACE 'spillspacelimit' | NODE GROUP logic_cluster_name | ACCOUNT { LOCK | UNLOCK } | PGUSER | AUTHINFO 'authinfo' | PASSWORD EXPIRATOIN period |
1 2 | ALTER USER user_name RENAME TO new_name; |
1 2 | ALTER USER user_name SET configuration_parameter { { TO | = } { value | DEFAULT } | FROM CURRENT }; |
1 2 | ALTER USER user_name RESET { configuration_parameter | ALL }; |
Specifies the current user name.
Value range: an existing user name
Indicates a new password.
A password must:
Value range: a string
Indicates the old password.
PGUSER of a user cannot be modified in the current version.
For details about other parameters, see "Parameter Description" in CREATE ROLE and ALTER ROLE.
Change the login password of user jim.
1 | ALTER USER jim IDENTIFIED BY '{password}' REPLACE '{old_password}'; |
Add the CREATEROLE permission to user jim.
1 | ALTER USER jim CREATEROLE; |
Set enable_seqscan to on (the setting will take effect in the next session).
1 | ALTER USER jim SET enable_seqscan TO on; |
Reset the enable_seqscan parameter for user jim.
1 | ALTER USER jim RESET enable_seqscan; |
Lock the jim account.
1 | ALTER USER jim ACCOUNT LOCK; |