All Products
Search
Document Center

PolarDB:ALTER USER

Last Updated:Mar 28, 2026

ALTER USER is now an alias for ALTER ROLE. All syntax and options described below are identical to ALTER ROLE.

Synopsis

ALTER USER role_specification [ WITH ] option [ ... ]

where option can be:

      SUPERUSER | NOSUPERUSER
    | CREATEDB | NOCREATEDB
    | CREATEROLE | NOCREATEROLE
    | INHERIT | NOINHERIT
    | LOGIN | NOLOGIN
    | REPLICATION | NOREPLICATION
    | BYPASSRLS | NOBYPASSRLS
    | CONNECTION LIMIT connlimit
    | [ ENCRYPTED ] PASSWORD 'password' | PASSWORD NULL
    | VALID UNTIL 'timestamp'

ALTER USER name RENAME TO new_name

ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] SET configuration_parameter { TO | = } { value | DEFAULT }
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] SET configuration_parameter FROM CURRENT
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] RESET configuration_parameter
ALTER USER { role_specification | ALL } [ IN DATABASE database_name ] RESET ALL

where role_specification can be:

    role_name
  | CURRENT_ROLE
  | CURRENT_USER
  | SESSION_USER

Examples

Change a user's password:

ALTER USER alice WITH PASSWORD 'new_password';

Remove a user's password:

ALTER USER alice WITH PASSWORD NULL;

Set a password expiration date:

ALTER USER alice VALID UNTIL 'January 1 00:00:00 2026 +0';

Make a password valid forever:

ALTER USER alice VALID UNTIL 'infinity';

Grant a user the ability to create databases and manage roles:

ALTER USER alice CREATEROLE CREATEDB;

Set a database-specific configuration parameter for a user:

ALTER USER alice IN DATABASE mydb SET client_min_messages = DEBUG;