-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathall_granted_roles.sql
42 lines (41 loc) · 949 Bytes
/
all_granted_roles.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
40
41
42
-- show all roles for a user, either directly assigned or nested via other roles
with user_role_hierarchy
as ( select
t2.name username, t1.granted_role
from
( select
distinct sa.userid, u.name granted_role
from
( select
t.*, connect_by_root grantee# userid
from
sys.sysauth$ t
connect by
prior privilege# = grantee#
) sa,
sys.user$ u
where
u.user# = sa.privilege#
and sa.userid in
( select
user#
from
sys.user$
where
type# = 1 -- normal users
or user# = 1 -- PUBLIC
)
) t1,
sys.user$ t2
where
t1.userid = t2.user#
)
select
*
from
user_role_hierarchy
where
username = '&user'
order by
granted_role
;