-
Notifications
You must be signed in to change notification settings - Fork 63
/
user_privs.sql
40 lines (34 loc) · 1.13 KB
/
user_privs.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
REM Script Name : user_privs.sql
REM Author : Craig Richards
REM Created : 20 May 2013
REM Last Modified :
REM Version : 1.0
REM
REM Modifications :
REM
REM Description : This code show all privileges for a given user or users, if you pass multiple users you need to do it like USER1','USER2','USER3 etc
SET PAGESIZE 200
SET LINESIZE 200
SET VERIFY OFF
COLUMN granted_by_role FORMAT a20
COLUMN obj_owner FORMAT a15
UNDEFINE Users;
SELECT a.grantee, b.privilege, a.granted_role AS GRANTED_BY_ROLE, NULL AS OBJECT, NULL AS OBJ_OWNER
FROM dba_role_privs a
JOIN dba_sys_privs b
ON a.granted_role=b.grantee
WHERE a.grantee IN ('&&Users')
UNION
SELECT grantee, privilege, 'n/a', NULL, NULL
FROM dba_sys_privs
WHERE grantee IN ('&&Users')
UNION
SELECT grantee, privilege, ' ', table_name, owner
FROM DBA_TAB_PRIVS
WHERE grantee IN ('&&Users')
UNION
SELECT username, 'QUOTA', DECODE(max_bytes, -1, 'unlimited', max_bytes/1024/1024) MAX_MB, 'TABLESPACE: ' || tablespace_name, NULL
FROM DBA_TS_QUOTAS
WHERE username IN ('&&Users')
ORDER BY grantee, privilege;
SELECT grantee,granted_role,admin_option FROM dba_role_privs WHERE grantee IN ('&&Users');