How can I grant the SELECT privilege on all sequences to a user using one statement? Somthing like:
GRANT SELECT ON <ALL SEQUENCES???> TO myUser
In PostgreSQL 9.x, you can grant permissions on all sequences in one schema to a role. The syntax is
GRANT SELECT
ON ALL SEQUENCES IN SCHEMA schema_name
TO role_name
The role can be either a group role or a login role (user name).
This will be very useful in the future:
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA schema_name TO your_user;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA schema_name TO your_user;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA schema_name TO your_user;
The accepted answer dont worked for me on 9.1. The below sentence did work:
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO user;
SELECT, USAGE
if you want to actually modify the sequence
Apr 18, 2014 at 1:00
It works in Postgres 13
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO admin;
For Postgres versions lower than 9.0
psql -d DBNAME -qAt -c "SELECT 'GRANT SELECT ON ' || relname || ' TO USER;' FROM pg_statio_all_sequences WHERE schemaname = 'public'" | psql -d DBNAME
Ref: http://gotochriswest.com/blog/2012/06/11/postgresql-granting-access-to-all-sequences/
nextval
)