Note
- In OceanBase Database V4.3.x, this view is introduced since V4.3.1.
- In OceanBase Database V4.2.x, this view is introduced since V4.2.3.
Purpose
The mysql.role_edges view displays the relationships between roles and users who are granted the roles.
Columns
| Column | Type | Nullable? | Description |
|---|---|---|---|
| FROM_HOST | varchar(255) | NO | The host name of the user that grants the role. |
| FROM_USER | varchar(128) | NO | The username of the user that grants the role. |
| TO_HOST | varchar(255) | NO | The host name of the user that is granted the role. |
| TO_USER | varchar(128) | NO | The username of the user that is granted the role. |
| WITH_ADMIN_OPTION | varchar(1) | NO | Indicates whether the granted role has the ADMIN privileges. |
Sample query
Query the relationship between the role1 role and the user001 user.
Create a role named
role1.obclient [oceanbase]> CREATE ROLE IF NOT EXISTS role1; Query OK, 0 rows affected, 1 warningGrant the
ALTER SYSTEMprivilege torole1.obclient [oceanbase]> GRANT ALTER SYSTEM ON *.* TO role1;Create a user named
user001.obclient [oceanbase]> CREATE USER 'user001'@'%' IDENTIFIED BY '******';Grant
role1touser001.obclient [oceanbase]>GRANT role001 TO user001 WITH ADMIN OPTION;;Query the relationship between
role1anduser001.obclient > SELECT * FROM mysql.role_edges;The query result is as follows:
+-----------+-----------+---------+---------+-------------------+ | FROM_HOST | FROM_USER | TO_HOST | TO_USER | WITH_ADMIN_OPTION | +-----------+-----------+---------+---------+-------------------+ | % | role001 | % | user001 | Y | +-----------+-----------+---------+---------+-------------------+ 1 row in set (0.001 sec)