我正在尝试设置一个新角色,以便更轻松地授予访问权限。我想知道是否有一种更简单的方法可以在选定用户的模式下对所有表(新创建的表应该可以自动访问)进行选择。我运行了以下查询。但我的用户仍然无法访问特定的表格。
CREATE ROLE myrole;
GRANT SELECT ON myschema.mytable TO myrole;
GRANT usage ON schema myschema TO myrole;
CREATE USER mytest1 identified BY '***';
GRANT myrole TO mytest1;
在此之后,当我使用mytest1用户登录并尝试在myschema.mytable上运行select时,它要求我将模式的使用授予用户。在我直接向用户授予对架构的使用后,它失败并且该表的权限被拒绝。
请帮助。我在vertica 5.0上运行
更新 我发现你还必须使该角色默认或明确地将该角色设置为用户会话的默认角色,以使角色发挥作用。
ALTER USER mytest1 DEFAULT ROLE myrole;
但是,我的另一个问题是如何让特定用户可以访问模式下的所有表格。
答案 0 :(得分:1)
根据Vertica SQL参考手册.pdf (第725页)(doc version 5.0 - for page number)
GRANT (Schema) ... USAGE Allows the user access to the objects contained within the schema. This allows the user to look up objects within the schema. Note that the user must also be granted access to the individual objects. See the GRANT TABLE (page 727) ... .
the user must also be granted access to the individual objects
表示您还需要GRANT table
。
我使用的是GRANT SELECT
和GRANT REFERENCES
,它允许用户在查询中运行查询和连接(引用)表。
示例:
GRANT SELECT ON TABLE [schema].[Table1] TO myUser;
GRANT SELECT ON TABLE [schema].[Table2] TO myUser;
GRANT REFERENCES ON TABLE [schema].[Table1] TO myUser;
GRANT REFERENCES ON TABLE [schema].[Table2] TO myUser;
...
6.0 doc参考GRANT SCHEMA
(第808页)和GRANT TABLE
(第813页)。