snowflake-cloud-data-platform - 授予数据库中的所有权限有什么作用?
问题描述
我尝试了以下授权,期望它授予对数据库中所有未来模式和表的读取访问权限test
。这授予了对当前表的访问权限,但未来的授予不起作用。
grant usage on all schemas in database test to role dev;
grant usage on future schemas in database test to role dev;
grant select on all tables in database test to role dev;
grant select on future tables in database test to role dev;
我必须运行以下命令才能让未来的赠款在模式 dw 中工作
grant select on all tables in schema test.dw to role dev;
grant select on future tables in schema test.dw to role dev;
第一批赠款做了什么?
解决方案
首次授权应授予角色 DEV 对任何模式中所有新表的访问权限。我试图重现这个问题:
create database test;
create role dev;
grant usage on all schemas in database test to role dev;
grant usage on future schemas in database test to role dev;
grant select on all tables in database test to role dev;
grant select on future tables in database test to role dev;
create schema test_schema;
create table test_table (name varchar);
show grants on schema test_schema;
+-------------------------------+-----------+------------+------------------+------------+--------------+--------------+--------------+
| created_on | privilege | granted_on | name | granted_to | grantee_name | grant_option | granted_by |
+-------------------------------+-----------+------------+------------------+------------+--------------+--------------+--------------+
| 2021-09-16 13:25:01.099 -0700 | OWNERSHIP | SCHEMA | TEST.TEST_SCHEMA | ROLE | ACCOUNTADMIN | true | ACCOUNTADMIN |
| 2021-09-16 13:25:01.101 -0700 | USAGE | SCHEMA | TEST.TEST_SCHEMA | ROLE | DEV | false | ACCOUNTADMIN |
+-------------------------------+-----------+------------+------------------+------------+--------------+--------------+--------------+
show grants on table test_table;
+-------------------------------+-----------+------------+-----------------------------+------------+--------------+--------------+--------------+
| created_on | privilege | granted_on | name | granted_to | grantee_name | grant_option | granted_by |
+-------------------------------+-----------+------------+-----------------------------+------------+--------------+--------------+--------------+
| 2021-09-16 13:25:02.280 -0700 | OWNERSHIP | TABLE | TEST.TEST_SCHEMA.TEST_TABLE | ROLE | ACCOUNTADMIN | true | ACCOUNTADMIN |
| 2021-09-16 13:25:02.337 -0700 | SELECT | TABLE | TEST.TEST_SCHEMA.TEST_TABLE | ROLE | DEV | false | ACCOUNTADMIN |
+-------------------------------+-----------+------------+-----------------------------+------------+--------------+--------------+--------------+
正如我所看到的,它按预期工作。您是否在该架构上定义了任何其他“未来授权”(对于任何其他角色)?当在数据库和模式级别都定义了未来的授权时,模式级别的授权优先于数据库级别的授权,并且数据库级别的授权被忽略。
https://docs.snowflake.com/en/sql-reference/sql/grant-privilege.html#considerations
推荐阅读
- mongodb-.net-driver - 如何在不使用 eval 的情况下在 Mongo C# Driver 中使用 Auto Increment 字段?
- javascript - 检索重定向到本地主机的 JSON - Angular 5
- android - 如何从 build.gradle 中的 json 配置文件创建 productFlavors?
- azure - Azure Active Directory - 企业应用程序组分配不起作用
- curl - telnet 连接被拒绝,curl 有效
- swagger - NelmioApiDoc 模型定义/如何忽略具有其他名称的现有属性的 getter 或别名?
- python - 使用 mayavi 进行实时绘图
- r - 如何使用 R 中的 download.file 和凭据从 SFTP 服务器下载文件
- ms-access - 查询中的字段名称无效
- elasticsearch - 在 elasticsearch 中设置存储库和快照