Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I list ALL grants a user received?

Tags:

sql

oracle

grant

I need to see all grants on an Oracle DB.

I used the TOAD feature to compare schemas but it does not shows temptable grants etc. so there's my question:

How can I list all grants on a Oracle DB?

like image 548
guerda Avatar asked Aug 19 '09 08:08

guerda


People also ask

How can I list all grants a user received in Oracle?

TYPE# in (2, 4, 42) and ue.name = 'your user' and bitand (o. flags, 128) = 0; This will list all object grants (including column grants) for your (specified) user.

How do I find grants on a schema?

select * from dba_role_privs where grantee = 'SCHEMA_NAME'; All the role granted to the schema will be listed. Thanks Szilagyi Donat for the answer.

Which SQL statement grants a privilege to all the database users?

You can use the SQL GRANT statement to grant SQL SELECT, UPDATE, INSERT, DELETE, and other privileges on tables or views. The WITH GRANT OPTION clause indicates that JONES can grant to other users any of the SQL privileges you granted for the ORDER_BACKLOG table.


1 Answers

If you want more than just direct table grants (e.g., grants via roles, system privileges such as select any table, etc.), here are some additional queries:

System privileges for a user:

SELECT PRIVILEGE   FROM sys.dba_sys_privs  WHERE grantee = <theUser> UNION SELECT PRIVILEGE    FROM dba_role_privs rp JOIN role_sys_privs rsp ON (rp.granted_role = rsp.role)  WHERE rp.grantee = <theUser>  ORDER BY 1; 

Direct grants to tables/views:

SELECT owner, table_name, select_priv, insert_priv, delete_priv, update_priv, references_priv, alter_priv, index_priv    FROM table_privileges  WHERE grantee = <theUser>  ORDER BY owner, table_name; 

Indirect grants to tables/views:

SELECT DISTINCT owner, table_name, PRIVILEGE    FROM dba_role_privs rp JOIN role_tab_privs rtp ON (rp.granted_role = rtp.role)  WHERE rp.grantee = <theUser>  ORDER BY owner, table_name; 
like image 86
DCookie Avatar answered Oct 27 '22 01:10

DCookie