Grant permissions to user for any new tables created in postgresql

后端 未结 3 875
没有蜡笔的小新
没有蜡笔的小新 2020-12-09 17:28

Currently I am using this to grant permissions:

grant select on all tables in schema public to ;

alter default privileges in schema public          


        
3条回答
  •  无人及你
    2020-12-09 18:29

    To grant default privileges, you need to grant to the user you are creating the table with.

    You are creating the tables as SA_user, but reading the tables as READ_user. Your code needs to look like:

    ALTER DEFAULT PRIVILEGES 
    FOR USER SA_user
    IN SCHEMA schema_name
    GRANT SELECT ON TABLES TO READ_user;
    

    So whenever the SA_user creates a table, it will grant select rights for the READ_user.

提交回复
热议问题