oracle user privileges 1

oracle user privileges

-- List privileges, including roles, for my_user
SELECT GRANTEE, PRIVILEGE AS PRIVILEGE_ROLE,
       NULL AS OWNER, NULL AS TABLE_NAME, NULL AS COLUMN_NAME,
       ADMIN_OPTION AS PRIVILEGE, 
       NULL AS GRANTABLE
FROM DBA_SYS_PRIVS WHERE GRANTEE = 'my_user'
UNION ALL
SELECT r.GRANTEE, r.GRANTED_ROLE AS PRIVILEGE_ROLE, p.OWNER, p.TABLE_NAME, 
	p.COLUMN_NAME, PRIVILEGE, p.GRANTABLE
FROM DBA_ROLE_PRIVS r LEFT JOIN ROLE_TAB_PRIVS p ON p.ROLE = r.GRANTED_ROLE
WHERE r.GRANTEE = 'my_user';

Here is what the above code is Doing:
1. The first SELECT statement is selecting all the privileges granted to my_user.
2. The second SELECT statement is selecting all the roles granted to my_user.
3. The third SELECT statement is selecting all the privileges granted to the roles granted to my_user.
4. The UNION ALL statement is combining the results of the first three SELECT statements.

Similar Posts