9951 explained code solutions for 126 technologies


postgresqlHow do I grant all privileges on a PostgreSQL schema?


To grant all privileges on a PostgreSQL schema, you can use the GRANT command. Here is an example of granting all privileges on a schema called "my_schema":

GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA my_schema TO my_user;

The code above grants all privileges (SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER, CREATE, CONNECT, TEMPORARY, EXECUTE, USAGE) on all tables in the specified schema (my_schema) to the specified user (my_user).

Code explanation

  • GRANT: This is the keyword for granting privileges.
  • ALL PRIVILEGES: This specifies that all privileges should be granted.
  • ON ALL TABLES IN SCHEMA: This specifies that the privileges should be granted on all tables in the specified schema.
  • my_schema: This is the name of the schema on which the privileges should be granted.
  • TO: This is the keyword for specifying the user to which the privileges should be granted.
  • my_user: This is the name of the user to which the privileges should be granted.

Helpful links

Edit this code on GitHub