ALTER USER username [ [ WITH ] option [ ... ] ] where option can be: [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' | CREATEDB | NOCREATEDB | CREATEUSER | NOCREATEUSER | VALID UNTIL 'abstime' |
The name of the user whose details are to be altered.
The new password to be used for this account.
These keywords control whether the password is stored encrypted in pg_shadow. (See CREATE USER for more information about this choice.)
These clauses establish the user's ability to create databases. If CREATEDB is specified, the user being defined will be allowed to create his own databases. NOCREATEDB will deny the user the ability to create databases.
These clauses determine whether a user will be permitted to create new users. This option will also make the user a superuser that can override all access restrictions.
The date (and, optionally, the time) at which this user's password will expire.
ALTER USER is used to change the attributes of a user's PostgreSQL account. Attributes not mentioned in the command retain their previous settings.
Only a database superuser can change privileges and password expiration with this command. Ordinary users can change only their own password.
Use CREATE USER to create a new user and DROP USER to remove a user.
ALTER USER cannot change a user's group memberships. Use ALTER GROUP to do that.
Create a user to be used in the following examples:
CREATE USER rhdb1; |
Change a user password:
ALTER USER rhdb1 WITH PASSWORD 'ke2fv9a'; |
ALTER USER rhdb1 VALID UNTIL 'Dec 31 2050'; |
ALTER USER chris VALID UNTIL 'May 4 12:00:00 2008 +1'; |
ALTER USER rhdb1 CREATEUSER CREATEDB; |