Purpose
This statement is mainly used for the following operations:
Modifying the password of a database user.
Modifying the profile used by a database user.
Modifying the encryption method for connecting to a database user. For other methods of modifying the password of a user, see SET PASSWORD.
Modifying the default roles of a database user.
Privilege requirements
In addition to the modification commands that the current user can execute, other users must have the ALTER USER privilege to execute this command to modify the information of other users. For more information about OceanBase Database privileges, see Privilege classification in Oracle mode.
Limitations
When a proxy user connects to a database on behalf of a target user, the current version only supports connecting to the database through OBClient, and the OBClient version must be V2.2.6 or later. Java and C drivers are not supported for connecting to the database.
Syntax
ALTER USER user_name
{ IDENTIFIED BY password
| PROFILE {"profile_name" | DEFAULT}
| REQUIRE {NONE | SSL | x509 | tls_option_list}
| DEFAULT ROLE
{ role_name[,role_name...]
| ALL [EXCEPT role_name[,role_name...]]
| NONE
}
| GRANT CONNECT THROUGH proxy_user_name [with_clause]
};
tls_option_list:
tls_option
| tls_option_list tls_option
tls_option:
CIPHER str_value
| ISSUER str_value
| SUBJECT str_value
with_clause:
WITH ROLE {role_name[, role_name,...]}
| WITH NO ROLE
| WITH ROLE ALL EXCEPT {role_name[, role_name,...]}
Parameters
| Parameter | Description |
|---|---|
| user_name | Specifies the username or the username of the target user being proxied. |
| IDENTIFIED BY | Specifies the new password of the user. |
| PROFILE | Specifies the profile used by the user.
|
| REQUIRE | Specifies the encryption protocol used by the user as NONE, SSL, X509, or tls_option_list. |
| DEFAULT ROLE | Specifies the default role for the user upon login.
|
| GRANT CONNECT THROUGH | Specifies the use of a proxy user. For more information on using proxy users, see Use a proxy user. |
| proxy_user_name | The username of the proxy user. After authorization, this user can connect to the database on behalf of the target user and use the roles and permissions of the target user to perform database operations. |
| with_clause | Specifies the roles and permissions that take effect when the proxy user connects to the database on behalf of the target user. If this clause is not specified, all roles and permissions of the target user take effect by default when the proxy user connects to the database on behalf of the target user. For more information, see with_clause. |
with_clause
Notice
When specifying the roles and permissions that take effect for the proxy user, for roles with passwords, you need to manually activate the role after connecting to the database using the SET ROLE role_name IDENTIFIED BY role_password; command.
WITH ROLE {role_name[, role_name,...]}: specifies the roles and permissions that take effect when the proxy user connects to the database on behalf of the target user, i.e., only the specified roles and permissions of the target user take effect.WITH NO ROLE: specifies that no roles and permissions of the target user take effect when the proxy user connects to the database on behalf of the target user.WITH ROLE ALL EXCEPT {role_name[ ,role_name,...]}: specifies the roles and permissions that take effect when the proxy user connects to the database on behalf of the target user, i.e., all roles and permissions of the target user except the specified ones take effect.
Examples
Modify the password of user
user1.obclient> ALTER USER user1 IDENTIFIED BY ******; Query OK, 0 rows affectedModify the encryption protocol for user
user1toSSL.obclient> ALTER USER user1 REQUIRE SSL; Query OK, 0 rows affectedModify the profile used by user
user1toprofile1.obclient> ALTER USER user1 PROFILE "profile1"; Query OK, 0 rows affectedSet the default role for user
user1.obclient> CREATE ROLE role1; Query OK, 0 rows affected obclient> CREATE ROLE role2 IDENTIFIED BY ******; Query OK, 0 rows affected obclient> CREATE ROLE role3 IDENTIFIED BY ******; 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
User
user1can directly use the permissions ofrole1. The permissions ofrole2androle3can be used by useruser1only after they are enabled in the session.For more information about enabling roles, see SET ROLE.
