如何在oracle中显示用户的所有权限?

2021-12-05 00:00:00 sql oracle rules privileges

谁能告诉我如何在 sql-console 中显示特定用户的所有权限/规则?

解决方案

您可以尝试以下视图.

SELECT * FROM USER_SYS_PRIVS;SELECT * FROM USER_TAB_PRIVS;SELECT * FROM USER_ROLE_PRIVS;

DBA 和其他高级用户可以使用这些相同视图的 DBA_ 版本找到授予其他用户的权限.它们包含在文档中.>

这些视图仅显示直接授予用户的权限.查找所有权限,包括通过角色间接授予的权限,需要更复杂的递归 SQL 语句:

select * from dba_role_privs connect by previous given_role = grantee start with grantee = '&USER' order by 1,2,3;select * from dba_sys_privs where grantee = '&USER' or grantee in (select grantee from dba_role_privs connect by previous given_role = grantee start with grantee = '&USER') order by 1,2,3;select * from dba_tab_privs where grantee = '&USER' or grantee in (select grantee from dba_role_privs connect by previous given_role = grantee start with grantee = '&USER') 按 1,2,3,4 排序;

Can someone please tell me how to show all privileges/rules from a specific user in the sql-console?

解决方案

You can try these below views.

SELECT * FROM USER_SYS_PRIVS; 
SELECT * FROM USER_TAB_PRIVS;
SELECT * FROM USER_ROLE_PRIVS;

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:

select * from dba_role_privs connect by prior granted_role = grantee start with grantee = '&USER' order by 1,2,3;
select * from dba_sys_privs  where grantee = '&USER' or grantee in (select granted_role from dba_role_privs connect by prior granted_role = grantee start with grantee = '&USER') order by 1,2,3;
select * from dba_tab_privs  where grantee = '&USER' or grantee in (select granted_role from dba_role_privs connect by prior granted_role = grantee start with grantee = '&USER') order by 1,2,3,4;

相关文章