简体   繁体   English

在 Snowflake 中查询具有给定权限授予的所有角色

[英]Query for all roles with a given privilege grant in Snowflake

Is there any means of querying Snowflake for all the roles (and/or users) where a specific privilege has been granted?是否有任何方法可以查询 Snowflake 以获取已授予特定权限的所有角色(和/或用户)? I know how to show grants to <role> but I'm not so sure of how to find the roles that have a grant.我知道如何show grants to <role>但我不太确定如何找到拥有授权的角色。

This is not something that needs to happen regularly--i'm just looking for ways to better understand this instance and its usage.这不是需要定期发生的事情——我只是在寻找更好地理解这个实例及其用法的方法。

Thanks to Himanshu , I was able to work out a query that answers my question exactly:感谢Himanshu ,我能够制定出一个准确回答我的问题的查询:

select distinct(grantee_name) from snowflake.account_usage.grants_to_roles -- this system view is updated every ~120 minutes
where privilege = 'USAGE' -- name of the privilege
and granted_on = 'WAREHOUSE' -- not strictly necessary, but name of the type of object
and name = 'MY_SPECIFIC_WAREHOUSE'; -- the important constraint for my case

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

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