ALTER USER

Description

Modifies user information, such as password or default roles.

NOTE

Individual users can use this command to modify information for themselves. user_admin can use this command to modify information for other users.

Syntax

ALTER USER <username> IDENTIFIED BY '<auth_string>' [DEFAULT ROLE { <role_name>[, <role_name>, ...] | ALL | NONE }]

Parameters

  • username: the username of the user to be altered.
  • auth_string: the password you set for the user.
  • DEFAULT ROLE: If this parameter is specified, the roles are automatically assigned to the user and activated by default when the user logs in. If it is not specified, this user does not have any privileges. Make sure that all the roles that are specified already exist. You can add the ALL keyword to assign all roles to the user. Or you can add the NONE keyword to assign NONE roles to the user except PUBLIC.

Examples

Example 1: Change the password of the user jack.

ALTER USER 'jack' IDENTIFIED BY '123456';

Example 2: Change the default roles of the user jack to db_admin and user_admin. Note that the user must have been assigned these two roles.

ALTER USER 'jack' DEFAULT ROLE db_admin, user_admin;

Example 3: Set all roles of the user jack, including roles that will be assigned to this user as default roles.

ALTER USER 'jack' DEFAULT ROLE ALL;

Example 4: Clear all the default roles of the user jack.

ALTER USER 'jack' DEFAULT ROLE NONE;

Note: By default, the public role is still activated for the user jack.

References