O'Reilly logo

PostgreSQL 9 Administration Cookbook - Second Edition by Simon Riggs, Gianni Ciolli, Hannu Krosing, Gabriele Bartolini

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.

Getting ready

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

How to do it…

Grant access to the schema containing the table, as follows:

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

How it works…

This sequence of commands first grants full access to all objects in that schema to a role, gives viewing (SELECT) and modifying (INSERT, UPDATE, and DELETE) rights on that table to the role, and then grants membership in that role to two database users.

There's more…

There is no requirement ...

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