Postgresql – Postgres: Permission denied for schema even though grants were given

grantpostgresql

I am running Postgres 10.4 and am currently baffled since I can't seem to grant access to a schema to another role.

What I want to do:

I have one role with one schema and want to access the schema and its tables from another role. So I did the usual (what worked with other schemas):

grant usage on schema myschema to newuser;

grant select on all tables in schema myschema to newuser;

Both of those statements were run as the owner of the schema. I didn't run into any errors while doing so.

When I log in as the newuser and try to select some data:

select * from myschema.table;

I get the error:

SQL Error [42501]: ERROR: permission denied for schema myschema

I can see that the newuser has the right privileges in the table "information_schema.role_table_grants"

It also worked with another role and another schema. I'm clueless.

Best Answer

Step 1
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA name_schema TO name_user;

Step 2
GRANT USAGE ON SCHEMA name_schema TO name_user;