List roles, system privileges and table privileges granted

Oracle Database Administration
Post Reply
User avatar
jimb
Site Admin
Posts: 6146
Joined: Thu Jan 19, 2012 1:10 pm
Location: New Delhi, India
Contact:

List roles, system privileges and table privileges granted

Post by jimb »

To list roles, system privileges and table privileges granted an Oracle user:

select
lpad(' ', 2*level) ||
granted_role "User, his roles and privileges"
from
(
/* THE USERS */
select
null grantee,
username granted_role
from
dba_users
where
username like upper('%&enter_username%')
/* THE ROLES TO ROLES RELATIONS */
union
select
grantee,
granted_role
from
dba_role_privs
/* THE ROLES TO PRIVILEGE RELATIONS */
union
select
grantee,
privilege
from
dba_sys_privs
)
start with grantee is null
connect by grantee = prior granted_role;


Sample Output:

Code: Select all

User, his roles and privileges
---------------------------------------------------------------------------------------------------------------------------------------------------
  SCOTT
    CONNECT
      CREATE SESSION
    RESOURCE
      CREATE CLUSTER
      CREATE INDEXTYPE
      CREATE OPERATOR
      CREATE PROCEDURE
      CREATE SEQUENCE
      CREATE TABLE
      CREATE TRIGGER
      CREATE TYPE
    UNLIMITED TABLESPACE
Oracle Database Administration Forums
http://www.oracle-forums.com/
xaeresis
Posts: 196117
Joined: Wed Oct 04, 2023 2:39 pm

Re: List roles, system privileges and table privileges granted

Post by xaeresis »

Post Reply