Purpose
You can use this statement to perform the following operations:
Change the password of a database user.
Change the profile used by a database user.
Change the encryption method of database user connections. For more information about how to change user passwords, see SET PASSWORD.
Change the primary zone of a database user.
Change the default role of a database user.
Note
To execute this statement on a user, except the current user, you must have the
ALTER USERprivilege.
Syntax
ALTER USER user_name
{ IDENTIFIED BY password
| PROFILE {"profile_name" | DEFAULT}
| PRIMARY_ZONE 'zone_name'
| REQUIRE {NONE | SSL | x509 | tls_option_list};
| DEFAULT ROLE
{ role_name[,role_name...]
| ALL [EXCEPT role_name[,role_name...]]
| NONE
}
};
tls_option_list:
tls_option
| tls_option_list tls_option
tls_option:
CIPHER str_value
| ISSUER str_value
| SUBJECT str_value
Parameters
| Parameter | Description |
|---|---|
| user_name | The username. |
| IDENTIFIED BY | The new password of the user. |
| PROFILE | The profile used by the user.
|
| PRIMARY_ZONE | The primary zone of the user. |
| REQUIRE | The encryption protocol for the user. Valid values: NONE, SSL, X509, and tls_option_list. |
| DEFAULT ROLE | The default role of the user during logon.
|
Examples
Change the password of
user1.obclient> ALTER USER user1 IDENTIFIED BY **1***; Query OK, 0 rows affectedChange the connection encryption protocol to
SSLforuser1.obclient> ALTER USER user1 REQUIRE SSL; Query OK, 0 rows affectedChange the profile used by
user1toprofile1.obclient> ALTER USER user1 PROFILE "profile1"; Query OK, 0 rows affectedChange the primary zone of
user1tozone2.obclient>ALTER USER user01 PRIMARY_ZONE 'zone2'; Query OK, 0 rows affectedSet the default roles of
user1.obclient> CREATE ROLE role1; Query OK, 0 rows affected obclient> CREATE ROLE role2 IDENTIFIED BY **2***; Query OK, 0 rows affected obclient> CREATE ROLE role3 IDENTIFIED BY **3***; Query OK, 0 rows affected obclient> GRANT role1,role2,role3 TO user1; Query OK, 0 rows affected obclient> ALTER USER user1 DEFAULT ROLE role1; Query OK, 0 rows affectedNote
user1can directly use the privileges ofrole1. To use the privileges ofrole2androle3,user1must first enablerole2androle3in the session.For more information about the statement for enabling roles, see SET ROLE.