mysql.role_edges

2024-06-28 05:30:30  Updated

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.

  1. Create a role named role1.

    obclient [oceanbase]> CREATE ROLE IF NOT EXISTS role1;
    Query OK, 0 rows affected, 1 warning
    
  2. Grant the ALTER SYSTEM privilege to role1.

    obclient [oceanbase]> GRANT ALTER SYSTEM ON *.* TO role1;
    
  3. Create a user named user001.

    obclient [oceanbase]> CREATE USER 'user001'@'%' IDENTIFIED BY '******';
    
  4. Grant role1 to user001.

    obclient [oceanbase]>GRANT role001 TO user001 WITH ADMIN OPTION;;
    
  5. Query the relationship between role1 and user001.

    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)
    

References

mysql.default_roles

Contact Us