View roles

2024-06-28 05:30:31  Updated

You can view roles in the system and the privileges of a role.

View roles by using views

You can view roles in the system, roles granted to a role, and the privileges of a role.

  • View roles in the system

    To view roles in the system, query the DBA_ROLES view as the administrator.

    obclient> SELECT * FROM DBA_ROLES;
    +---------------------+-------------------+---------------------+
    | ROLE                | PASSWORD_REQUIRED | AUTHENTICATION_TYPE |
    +---------------------+-------------------+---------------------+
    | CONNECT             | NO                | NONE                |
    | RESOURCE            | NO                | NONE                |
    | DBA                 | NO                | NONE                |
    | PUBLIC              | NO                | NONE                |
    | STANDBY_REPLICATION | NO                | NONE                |
    | ROLE1               | NO                | NONE                |
    +---------------------+-------------------+---------------------+
    6 rows in set
    

    For more information about fields in the DBA_ROLES view, see DBA_ROLES.

  • View roles granted to a role

    To view roles granted to a role, query the ROLE_ROLE_PRIVS view. If no roles are granted to the role, no result is returned.

    obclient> SELECT * FROM ROLE_ROLE_PRIVS WHERE role='ROLE1';
    +-------+--------------+--------------+
    | ROLE  | GRANTED_ROLE | ADMIN_OPTION |
    +-------+--------------+--------------+
    | ROLE1 | ROLE2        | NO           |
    +-------+--------------+--------------+
    1 row in set
    

    For more information about fields in the ROLE_ROLE_PRIVS view, see ROLE_ROLE_PRIVS.

  • View the system privileges of a role

    To view the system privileges of a role, query the ROLE_SYS_PRIVS view as an administrator.

    obclient> SELECT * FROM ROLE_SYS_PRIVS WHERE role='CONNECT';
    +---------+----------------+--------------+
    | ROLE    | PRIVILEGE      | ADMIN_OPTION |
    +---------+----------------+--------------+
    | CONNECT | CREATE SESSION | NO           |
    +---------+----------------+--------------+
    1 row in set
    

    For more information about fields in the ROLE_SYS_PRIVS view, see ROLE_SYS_PRIVS.

  • View the object privileges of a role

    To view the object privileges of a role, query the ROLE_TAB_PRIVS view.

    obclient> SELECT * FROM ROLE_TAB_PRIVS WHERE role='ROLE1';
    +-------+-------+------------+-------------+-----------+-----------+
    | ROLE  | OWNER | TABLE_NAME | COLUMN_NAME | PRIVILEGE | GRANTABLE |
    +-------+-------+------------+-------------+-----------+-----------+
    | ROLE1 | SYS   | T1         | NULL        | SELECT    | NO        |
    +-------+-------+------------+-------------+-----------+-----------+
    1 row in set
    

    For more information about fields in the ROLE_TAB_PRIVS view, see ROLE_TAB_PRIVS.

Contact Us