How to create a read only user in Postgresql

Today I worked on an apparently simple problem. I would like to create a readonly user in postgresql database. This user must have read only rights on a specified schema which is not the public schema.

The first thing that you should know is that only the shema’s owner can grant privileges on the specified schema. Even if you done it with a superuser, you wont be able to grant the desired rights.

First of all, create the user :

Grant privileges on existing objects (i.e already created tables) :

Grant privileges on new objects (i.e future tables) :

 

Leave a Reply