O'Reilly logo

PostgreSQL 9 Administration Cookbook by Hannu Krosing, Simon Riggs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Granting user access to a table

A user needs to have access to a table in order to perform any action on it. Although the default behavior of PostgreSQL database is to give full access to all users through role PUBLIC, a security-conscious database setup revokes rights from PUBLIC after table creation.

Getting ready

Make sure that you have appropriate "roles" defined, and that privileges are "revoked" from role PUBLIC.

How to do it...

Grant access to schema containing the table to:

GRANT ALL ON someschema TO somerole;
GRANT SELECT, INSERT, UPDATE, DELETE ON someschema.sometable TO somegroup;
GRANT somerole TO someuser, otheruser;

How it works...

This sequence of commands first grants full access in schema to a role, gives viewing (SELECT) and modifying ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required