GRANT SELECT privilege to ALL sequences using one statement

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

Answers


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;

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/


Need Your Help

How to adjust the height of a textview to his content in SWIFT?

ios swift autolayout uitextview

In my view controller, I have an UITextView. This textview is filled with a string. The string can be short or long. Depending on the length of the string, the height of the textview has to adjust....

What are the different types of indexes, what are the benefits of each?

sql database database-design indexing

What are the different types of indexes, what are the benefits of each?