Skip to content

Instantly share code, notes, and snippets.

@tothda
Created November 19, 2008 08:29
Show Gist options
  • Save tothda/26459 to your computer and use it in GitHub Desktop.
Save tothda/26459 to your computer and use it in GitHub Desktop.
select
case when level = 1 then own || '.' || obj || ' (' || typ || ')' else
lpad (' ', 2*(level-1)) || obj || nvl2 (typ, ' (' || typ || ')', null)
end
from
(
/* THE OBJECTS */
select
null p1,
null p2,
object_name obj,
owner own,
object_type typ
from
dba_objects
where
owner like upper('%&enter_owner_name%')
and object_name like upper('%&enter_object_name%')
/* THE OBJECT TO PRIVILEGE RELATIONS */
union
select
table_name p1,
owner p2,
grantee,
grantee,
privilege
from
dba_tab_privs
/* THE ROLES TO ROLES/USERS RELATIONS */
union
select
granted_role p1,
granted_role p2,
grantee,
grantee,
null
from
dba_role_privs
)
start with p1 is null and p2 is null
connect by p1 = prior obj and p2 = prior own;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment