Marco
Marco

Reputation: 35

Postgres: GRANT usage on schema myschema to myrole; Error

I'm new to Postgres (worked with Oracle the last 23 years). I would like to grant the usage on schema to role. But that seems to be impossible:

ps >create role marco_role;
CREATE ROLE
ps >create schema myschema;
CREATE SCHEMA
ps >grant usage on myschema to marco_role;
FEHLER:  Relation »myschema« existiert nicht (English: Relation does not exists)

What is my problem?

Upvotes: 1

Views: 4558

Answers (1)

user330315
user330315

Reputation:

To grant privileges on a schema you need to use ON SCHEMA as documented in the manual

grant usage ON SCHEMA myschema to marco_role;

You probably also want to define default privileges for new tables (that are not yet created) as well:

alter default privileges  
   in schema myschema
   grant select on tables to marco_role;

Upvotes: 2

Related Questions