ALTER USER

Name

ALTER USER  --  Modifies user account properties and permissions.

Synopsis

ALTER USER username
    [ WITH PASSWORD 'password' ]
    [ CREATEDB | NOCREATEDB ] [ CREATEUSER | NOCREATEUSER ]
    [ VALID UNTIL 'abstime' ]
  

Parameters

username

This parameter takes the name of the account to be modified.

password

If you are changing an account's password, use this parameter to provide the database with a new password for the account.

CREATEDB, NOCREATEDB

Use these keywords to determine whether or not an account has permission to create databases. CREATEDB will specify that the account is able to create databases, whereas NOCREATEDB will deny a user the privileges needed to create databases.

CREATEUSER, NOCREATEUSER

Use these keywords to set whether or not a user has permission to create other users.

NoteSuperuser
 

Specifying that an account is able to create other users also automatically classifies the user as a superuser on the database; this can be quite the security risk if unintentional , as a superuser account can override other access restrictions.

abstime

To force an account's password to expire after a certain amount of time, enter the date on which this should happen (and, optionally, the time).

Results

ALTER USER

This message is displayed if the modification is successful.

ERROR: ALTER USER: user "username" does not exist

If it was impossible for the modification to be made, the database will display this error.

Description

Use the ALTER USER to change the attributes and permissions of a PostgreSQL user account.

NoteSuperusers only!
 

Only a database superuser can change privileges and password expiration values with this command. Ordinary users are only permitted to change their password.

To create and remove user accounts, use the CREATE USER command and the DROP USER command, respectively.

Examples

The following example changes the password for user mark:

ALTER USER mark WITH PASSWORD 'ml0215em';

The next example demonstrates changing the valid until-date for the user account mark.

ALTER USER mark VALID UNTIL 'Dec 30 2012';