简体   繁体   English

表中权限查询的区别

[英]Difference between query of privileges in tables

Reading this answe r I found a query to find the privileges of a table:阅读这个答案我发现了一个查询来查找表的权限:

SELECT * FROM ALL_TAB_PRIVS WHERE TABLE_NAME = 'MY_TABLE'

But a friend give me to me this query:但是一个朋友给了我这个查询:

select a.USERNAME,a.GRANTED_ROLE,b.ROLE,b.owner,b.TABLE_NAME,b.privilege
from user_role_privs a,role_tab_privs b
where b.ROLE=a.GRANTED_ROLE and b.TABLE_NAME = 'MY_TABLE';

There is some substantial difference between each query?每个查询之间有一些实质性的区别吗?

They are quite different, yes.他们完全不同,是的。

In Oracle, privileges on a table can be granted either directly to a user (in which case they would appear in ALL_TAB_PRIVS ) or privileges can be granted to a role (visible in ROLE_TAB_PRIVS ) and that role can be granted to a user (visible in USER_ROLE_PRIVS ).在 Oracle 中,可以将表的权限直接授予用户(在这种情况下,它们将出现在ALL_TAB_PRIVS )或可以将权限授予角色(在ROLE_TAB_PRIVS可见),并且该角色可以授予用户(在ALL_TAB_PRIVS可见) USER_ROLE_PRIVS )。 The first query will show you the users that have direct grants on a table.第一个查询将向您显示对表具有直接授权的用户。 The second query will show you the users that have been granted a role that has been granted access to the table (note that in both cases you really ought to specify an OWNER in addition to the table name).第二个查询将向您显示已被授予访问表的角色的用户(请注意,在这两种情况下,除了表名之外,您确实应该指定一个OWNER )。 Neither will show you information about grants that have been made through multiple nested levels of roles (ie User A has been granted Role 1, Role 1 has been granted Role 2, Role 2 has been granted access to a table).两者都不会向您显示有关通过多个嵌套级别的角色进行的授权的信息(即,用户 A 已被授予角色 1,角色 1 已被授予角色 2,角色 2 已被授予访问表的权限)。 Grants made via roles can also get a bit tricky because there are default and non-default roles and password protected roles and roles can be enabled and disabled in a session.通过角色授予的权限也可能有点棘手,因为有默认和非默认角色以及密码保护的角色和角色,可以在会话中启用和禁用。

In general, I'd suggest taking a look at the scripts available on Pete Finnigan's site if you want to have something that covers all the possible cases.一般来说,如果您想拥有涵盖所有可能情况的内容,我建议您查看Pete Finnigan 网站上提供脚本 In this case, you probably want to use his who_can_access script to determine what users can access a particular table.在这种情况下,您可能希望使用他的who_can_access 脚本来确定哪些用户可以访问特定表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM