purplefloyd
purplefloyd

Reputation: 155

How to create a read-only user in postgres for all schema?

I am wondering if anyone knows a command to create a read-only user for all schemas and tables in a postgres DB. I have found ways to do it for specific tables and specific schemas but not across the board (we have many schemas and I would rather not run the command 60+ times). Thanks in advance

Upvotes: 2

Views: 1069

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246523

There is no simple way to do that in PostgreSQL.

What you should do is create a role that has read access to all tables (and yes, you'll have to run at least one GRANT statement per schema) and grant that role to all login users that need read access.

That way you have to do the work only once, and dropping the user becomes so much easier.

Upvotes: 2

Related Questions