Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grant privileges to all users, current and future

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.

like image 751
lubar Avatar asked Jan 09 '13 20:01

lubar


People also ask

How do I grant all privileges to user?

To GRANT ALL privileges to a user , allowing that user full control over a specific database , use the following syntax: mysql> GRANT ALL PRIVILEGES ON database_name.

What does grant all privileges do?

Use the ALL PRIVILEGES privilege type to grant all of the privileges to the user or role for the specified table. You can also grant one or more table privileges by specifying a privilege-list. Use the DELETE privilege type to grant permission to delete rows from the specified table.

Which keyword is used when the privileges are to be granted to all users?

grantees. You can grant privileges or roles to specific users or roles or to all users. Use the keyword PUBLIC to specify all users.


1 Answers

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

like image 61
a_horse_with_no_name Avatar answered Sep 17 '22 09:09

a_horse_with_no_name