DOYENSYS Knowledge Portal




We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal




Wednesday, June 29, 2016

Find Roles and Privelages for USER

Following query will be useful to findout Roles and Privileges assigned to a user.

Here, used SCOTT as User:

COL "USER,HIS ROLES AND PRIVILEGES" FORMAT a100
set linesize 300 pages 1000
SELECT
LPAD(' ', 5*level) || granted_role "USER,HIS ROLES AND PRIVILEGES"
FROM
(
  SELECT NULL grantee, username granted_role
  FROM dba_users
  WHERE username LIKE UPPER('SCOTT')
  UNION
  SELECT grantee,granted_role
  FROM dba_role_privs
  UNION
  SELECT grantee,privilege
  FROM dba_sys_privs
)
START WITH grantee IS NULL
CONNECT BY grantee = PRIOR granted_role;

Sample Output:

USER,HIS ROLES AND PRIVILEGES
-------------------------------------------
     SCOTT
          CREATE MATERIALIZED VIEW
          CREATE SESSION
          CREATE TABLE
          CREATE TYPE
          CREATE VIEW
          RESOURCE
               CREATE CLUSTER
               CREATE INDEXTYPE
               CREATE OPERATOR
               CREATE PROCEDURE
               CREATE SEQUENCE
               CREATE TABLE
               CREATE TRIGGER
               CREATE TYPE
          UNLIMITED TABLESPACE

16 rows selected.

SQL>

No comments: