← Users & Privileges
Oracle · Users & Privileges

How to find roles granted to a user in Oracle

Show the roles granted to an Oracle user, including nested role-to-role grants, as an indented tree.

Tested on11g12c19c21c23ai26ai

The roles granted to a user, expanded through role-to-role grants and shown as an indented tree, so you can see where a privilege really comes from. Prompts for a username.

SELECT LPAD(' ', 2 * (LEVEL - 1)) || granted_role AS role_tree,
       admin_option,
       default_role,
       LEVEL AS depth
FROM   dba_role_privs
START  WITH grantee = UPPER('&&username')
CONNECT BY PRIOR granted_role = grantee
ORDER  SIBLINGS BY granted_role;
rolesdba_role_privs