{"id":148,"date":"2015-03-11T22:14:37","date_gmt":"2015-03-12T02:14:37","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/2015\/03\/11\/oracle-role-hierarchy-report\/"},"modified":"2015-03-11T22:14:37","modified_gmt":"2015-03-12T02:14:37","slug":"oracle-role-hierarchy-report","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2015\/03\/11\/oracle-role-hierarchy-report\/","title":{"rendered":"Oracle role hierarchy report"},"content":{"rendered":"<p>The SQL below can be used to provide a list of roles that inherits the CONNECT role, and with the use of START WITH clause, it will also iterate through all the roles beneath those roles, thus providing a hierarchy report.<\/p>\n<pre class=\"code\">\nselect level, drp.granted_role, rpad('-',6*level,'-')||drp.grantee as grantee,\ncase\n\twhen u.username is not null and account_status='OPEN' then 'Ua'\n\twhen u.username is not null and account_status<>'OPEN' then 'Ux'\n\twhen r.role is not null then 'R'\nend as grantee_type\nfrom dba_role_privs drp, dba_users u, dba_roles r\nwhere drp.grantee=u.username(+) and drp.grantee=r.role(+)\nstart with drp.granted_role='CONNECT'\nconnect by prior drp.grantee=drp.granted_role;\n<\/pre>\n<p>Below is a sample of what may be returned.<\/p>\n<table>\n<tr>\n<td><b>LEVEL<\/b><\/td>\n<td><b>GRANTED_ROLE<\/b><\/td>\n<td><b>GRANTEE<\/b><\/td>\n<td><b>GRANTEE_TYPE<\/b><\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>CONNECT<\/td>\n<td>&#8212;&#8212;ADMINS<\/td>\n<td>R<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>ADMINS<\/td>\n<td>&#8212;&#8212;&#8212;&#8212;ANDER<\/td>\n<td>Ua<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>ADMINS<\/td>\n<td>&#8212;&#8212;&#8212;&#8212;MARY<\/td>\n<td>Ux<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>ADMINS<\/td>\n<td>&#8212;&#8212;&#8212;&#8212;ZOE<\/td>\n<td>Ua<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>CONNECT<\/td>\n<td>&#8212;&#8212;EMPLOYEES<\/td>\n<td>R<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>EMPLOYEES<\/td>\n<td>&#8212;&#8212;&#8212;&#8212;ACCOUNTING<\/td>\n<td>R<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>ACCOUNTING<\/td>\n<td>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;DEBBIE<\/td>\n<td>Ua<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>EMPLOYEES<\/td>\n<td>&#8212;&#8212;&#8212;&#8212;OPERATIONS<\/td>\n<td>R<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>OPERATIONS<\/td>\n<td>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;PETER<\/td>\n<td>Ua<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>OPERATIONS<\/td>\n<td>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;WILLEM<\/td>\n<td>Ua<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>This article provides one way to report the hierarchy of roles in an Oracle environment.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-148","post","type-post","status-publish","format-standard","hentry","category-oracle"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/comments?post=148"}],"version-history":[{"count":0,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/148\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}