Can someone please tell me how to show all privileges/rules from a specific user in the sql-console?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
You can try these below views.
DBAs and other power users can find the privileges granted to other users with the
DBA_
versions of these same views. They are covered in the documentation .Those views only show the privileges granted directly to the user. Finding all the privileges, including those granted indirectly through roles, requires more complicated recursive SQL statements:
There are various scripts floating around that will do that depending on how crazy you want to get. I would personally use Pete Finnigan's find_all_privs script.
If you want to write it yourself, the query gets rather challenging. Users can be granted system privileges which are visible in
DBA_SYS_PRIVS
. They can be granted object privileges which are visible inDBA_TAB_PRIVS
. And they can be granted roles which are visible inDBA_ROLE_PRIVS
(roles can be default or non-default and can require a password as well, so just because a user has been granted a role doesn't mean that the user can necessarily use the privileges he acquired through the role by default). But those roles can, in turn, be granted system privileges, object privileges, and additional roles which can be viewed by looking atROLE_SYS_PRIVS
,ROLE_TAB_PRIVS
, andROLE_ROLE_PRIVS
. Pete's script walks through those relationships to show all the privileges that end up flowing to a user.You can use below code to get all the privileges list from all users.
Another useful resource:
http://psoug.org/reference/roles.html
While Raviteja Vutukuri's answer works and is quick to put together, it's not particularly flexible for varying the filters and doesn't help too much if you're looking to do something programmatically. So I put together my own query:
Advantages:
WHERE
clause.DBMS_OUTPUT
or something (compared to Pete Finnigan's linked script). This makes it useful for programmatic use and for exporting.GRANT
.