postgresql – 错误:在字符46处拒绝模式user1_gmail_com的权限

postgresql – 错误:在字符46处拒绝模式user1_gmail_com的权限,第1张

概述我需要限制一个用户,只访问一个特定的schema表。所以我尝试以下的查询和登录为user1_gmail_com。但是当我尝试浏览任何模式表时,我收到以下错误。 我的查询: SELECT clone_schema('my_application_template_schema','user1_gmail_com');CREATE USER user1_gmail_com WITH PASSWORD 我需要限制一个用户,只访问一个特定的schema表。所以我尝试以下的查询和登录为user1_gmail_com。但是当我尝试浏览任何模式表时,我收到以下错误。

我的查询:

SELECT clone_schema('my_application_template_schema','user1_gmail_com');CREATE USER user1_gmail_com WITH PASSWORD 'myloginpassword';REVOKE  ALL ON ALL tableS IN SCHEMA user1_gmail_com FROM PUBliC;GRANT SELECT ON ALL tableS IN SCHEMA user1_gmail_com TO user1_gmail_com;

sql错误:

ERROR:  permission denIEd for schema user1_gmail_com at character 46In statement:SELECT COUNT(*) AS total FROM (SELECT * FROM "user1_gmail_com"."organisations_table") AS sub

更新工作查询

SELECT clone_schema('my_application_template_schema','user1_gmail_com');CREATE USER user1_gmail_com WITH PASSWORD 'myloginpassword';REVOKE  ALL ON ALL tableS IN SCHEMA user1_gmail_com FROM PUBliC;GRANT USAGE ON SCHEMA user1_gmail_com TO user1_gmail_com;GRANT SELECT ON ALL tableS IN SCHEMA user1_gmail_com TO user1_gmail_com;
您不仅需要授予对架构中的表的访问权限,还可以授予架构本身的访问权限。

从manual:

By default,users cannot access any objects in schemas they do not own. To allow that,the owner of the schema must grant the USAGE privilege on the schema.

因此,要么将创建的用户设置为模式的所有者,要么将该模式的USAGE授予该用户。

总结

以上是内存溢出为你收集整理的postgresql – 错误:在字符46处拒绝模式user1_gmail_com的权限全部内容,希望文章能够帮你解决postgresql – 错误:在字符46处拒绝模式user1_gmail_com的权限所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1170980.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存