Grant privileges to all users, current and future

2019-07-02 07:01发布

问题:

I have a multi-schema, multi-user Postgres DB. There is one table that I would like ALL users, both current and future, to be able to SELECT from.

I can GRANT SELECT to all current users... but how can I create a table that allows any future user to select? Is there a way to set table permissions, rather than granting user privileges?

A filesystem analogy would be using chmod to make a file to be readable by the public.

回答1:

grant select on the_table to public;

From the manual:

The key word PUBLIC indicates that the privileges are to be granted to all roles, including those that might be created later. PUBLIC can be thought of as an implicitly defined group that always includes all roles