Quantcast
Channel: Doyensys Allappsdba Blog..
Viewing all articles
Browse latest Browse all 1640

Find Roles and Privelages for USER

$
0
0
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>

Viewing all articles
Browse latest Browse all 1640

Trending Articles