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.
Step 1GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA name_schema TO name_user;
Step 2GRANT USAGE ON SCHEMA name_schema TO name_user;
It definitely works as posted in my question, the problem was that I didn't user the owner of the schema.
So always make sure you grant access to a schema from the owner role.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With