|
|
Question : Get view privileges granted to roles
|
|
We can get table privileges granted to roles by: SELECT DBMS_METADATA.GET_GRANTED_DDL('OBJECT_GRANT', role) from ROLE_TAB_PRIVS; But how to get view privileges granted to roles?
|
Answer : Get view privileges granted to roles
|
|
I add this view to the data dictionary, then select from it. Note that it has a column "table_name" but that column includes views, procedures, etc. You could change that "object_name" instead and also get the column "object_type" from sys.obj$.
create or replace view table_privs (GRANTEE, OWNER, TABLE_NAME, GRANTOR, PRIVILEGE, GRANTABLE, GRANT_ID) as select substr(ue.name,1,24), substr(u.name,1,13), substr(o.name,1,30), substr(ur.name,1,13), substr(tpm.name,1,10), decode(oa.option$, 1, 'YES', 'NO'), oa.sequence# from sys.objauth$ oa, sys.obj$ o, sys.user$ u, sys.user$ ur, sys.user$ ue, table_privilege_map tpm where oa.obj# = o.obj# and oa.grantor# = ur.user# and oa.grantee# = ue.user# and oa.col# is null and u.user# = o.owner# and oa.privilege# = tpm.privilege and (userenv('SCHEMAID') in (oa.grantor#, oa.grantee#, o.owner#) or oa.grantee# = 1) -- grantee# 1 = "PUBLIC"; -- create public synonym table_privs for sys.table_privs; grant select on table_privs to public;
|
|
|
|
|