Purpose
You can use this statement to modify the username of a user that has logged on to OceanBase Database.
Note
To execute this statement, you must have the
CREATE USERprivilege.
Syntax
RENAME USER
'old_user_name' TO 'new_user_name'
[,'old_user_name' TO 'new_user_name'...];
Parameters
| Parameter | Description |
|---|---|
| old_user_name | The old username. |
| new_user_name | The new username. The username can contain up to 16 bytes in length. |
| 'old_user_name' TO 'new_user_name' | The operation to modify the username. Multiple usernames must be separated with commas (,). User privileges remain unchanged after the username is modified. |
Examples
Before you modify the username, execute the following statement to query the user.
Result:
obclient> SELECT user FROM mysql.user; +-----------+ user +-----------+ root admin sqluser01 sqluser02 +-----------+ 4 rows in set (0.00 sec)Execute the following statement to change the username of
sqluser01toobsqluser01.obclient> RENAME USER 'sqluser01' TO 'obsqluser01';After you modify the username, execute the following statement to query the user. Result:
The username of
sqluser01has been changed toobsqluser01.obclient> RENAME USER 'sqluser01' TO 'obsqluser01'; Query OK, 0 rows affected (0.04 sec) obclient> SELECT user FROM mysql.user; +-------------+ user +-------------+ root admin obsqluser01 sqluser02 +-------------+ 4 rows in set (0.00 sec)