我需要限制一个用户,只访问一个特定的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;
ERROR: permission denied for schema user1_gmail_com at character 46 In 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;