Given a Oracle normal(not DBA) user I need to find what objects which are not owned by the user he has permissions on and how it was granted(through what role or direct grant).
Can you write a simple script for this.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think this should get you pretty much what you need. ALL_TAB_PRIVS is available to all users in the database and lists all objects that the user performing the SELECT has permissions on, what the permission is, and who granted it. I’ve joined it to another view, ROLE_TAB_PRIVS, to find the role that granted the privilege to the user, if any. If the user was granted permissions via a role and a direct grant, both are listed.
EDIT:
ALL_TAB_PRIVS is a bit of a misnomer, as it includes PL/SQL executable objects as well.
EDIT 2:
It appears that this leaves out views. You could union the all_views results with the above query to give all the views you have some sort of access to, although I’m not sure at the moment how to give you the exact privileges you have been granted on the views.
A word of warning: including all the SYS objects you have access gives you a rather voluminous list. You may wish to filter out objects belonging to SYS, as I’ve shown here.