ALTER USER username [ WITH PASSWORD 'password' ] [ CREATEDB | NOCREATEDB ] [ CREATEUSER | NOCREATEUSER ] [ VALID UNTIL 'abstime' ]
The name of the PostgreSQL database user to be modified.
An optional new password to assign to the modified PostgreSQL user.
The privilege to create new databases. Use CREATEDB, to give the user permission to create databases. Use NOCREATEDB to explicitly deny that permission (which is the default).
The superuser privilege. The use of CREATEUSER allows access to both the CREATE USER and DROP USER commands, as well as makes the user a superuser (with universal rights across all databases). NOCREATEUSER is the default.
Specifying that a PostgreSQL user is able to create other users also automatically classifies the user as a superuser in the database; this can be a security risk if unintentional. A superuser can override all other access restrictions.
The timestamp that defines when a user's password expires. When the date and time defined by abstime is reached, the user's defined password will become invalid. If unset, the password never expires.
Use the ALTER USER to change the attributes and permissions of a PostgreSQL database user.
Note: Only a database superuser can change privileges and password expiration values with ALTER USER. Ordinary users are only permitted to change their own password.
To create and remove PostgreSQL database users, use the CREATE USER command and the DROP USER command, respectively.
The following example changes the password for user mark:
booktown=# ALTER USER mark WITH PASSWORD 'ml0215em'; ALTER USER
The next example demonstrates changing the password expiration date for the user mark:
booktown=# ALTER USER mark VALID UNTIL 'Dec 24 2012'; ALTER USER