---
name: "alter_user"
section: "7l"
platform: "linux"
package: "postgresql-client"
version: "7.2.1-2woody8"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/alter_user/7l"
---

# alter\_user(7l)

change a database user account

## NAME

ALTER USER - change a database user account

## SYNOPSIS

```
ALTER USER username [ [ WITH ] option [ ... ] ]
where option can be:
	  [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
        | CREATEDB | NOCREATEDB
        | CREATEUSER | NOCREATEUSER
        | VALID UNTIL 'abstime'

```

### INPUTS

- *username*

  The name of the user whose details are to be altered.

- *password*

  The new password to be used for this account.

- **ENCRYPTED**

  - **UNENCRYPTED**

  These keywords control whether the password is stored encrypted in pg\_shadow. (See CREATE USER \[**create\_user**(l)\] for more information about this choice.)

- **CREATEDB**

  - **NOCREATEDB**

  These clauses define a user's ability to create databases. If CREATEDB is specified, the user being defined will be allowed to create his own databases. Using NOCREATEDB will deny a user the ability to create databases.

- **CREATEUSER**

  - **NOCREATEUSER**

  These clauses determine whether a user will be permitted to create new users himself. This option will also make the user a superuser who can override all access restrictions.

- *abstime*

  The date (and, optionally, the time) at which this user's password is to expire.

### OUTPUTS

- **ALTER USER**

  Message returned if the alteration was successful.

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

  Error message returned if the specified user is not known to the database.

## DESCRIPTION

**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 only change their own password.

**ALTER USER** cannot change a user's group memberships. Use ALTER GROUP \[**alter\_group**(l)\] to do that.

Use CREATE USER \[**create\_user**(l)\] to create a new user and DROP USER \[**drop\_user**(l)\] to remove a user.

## USAGE

Change a user password:

```
ALTER USER davide WITH PASSWORD 'hu8jmn3';

```

Change a user's valid until date:

```
ALTER USER manuel VALID UNTIL 'Jan 31 2030';

```

Change a user's valid until date, specifying that his authorization should expire at midday on 4th May 1998 using the time zone which is one hour ahead of UTC:

```
ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1';

```

Give a user the ability to create other users and new databases:

```
ALTER USER miriam CREATEUSER CREATEDB;

```

## COMPATIBILITY

### SQL92

There is no **ALTER USER** statement in SQL92. The standard leaves the definition of users to the implementation.
