Skip to Content
PostgreSQL 10 Administration Cookbook - Fourth Edition
book

PostgreSQL 10 Administration Cookbook - Fourth Edition

by Simon Riggs, Gianni Ciolli
May 2018
Intermediate to advanced content levelIntermediate to advanced
576 pages
30h 25m
English
Packt Publishing
Content preview from PostgreSQL 10 Administration Cookbook - Fourth Edition

How to do it…

The steps are as follows:

  1. Create user roles with no privileges and with the NOINHERIT option:
postgres=# create user alice noinherit;CREATE ROLEpostgres=# create user bob noinherit; CREATE ROLE
  1. Then, create roles for each group of privileges that you need to assign:
postgres=# create group sales; CREATE ROLEpostgres=# create group marketing; CREATE ROLEpostgres=# grant postgres to marketing; GRANT ROLE
  1. Now grant each user the roles it may need:
postgres=# grant sales to alice; GRANT ROLEpostgres=# grant marketing to alice; GRANT ROLEpostgres=# grant sales to bob; GRANT ROLE

After you do this, the users alice and bob have no rights after login, but they can assume the sales role by executing SET ROLE TO  sales, and alice ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PostgreSQL 13 Cookbook

PostgreSQL 13 Cookbook

Vallarapu Naga Avinash Kumar
PostgreSQL 9 Administration Cookbook - Second Edition

PostgreSQL 9 Administration Cookbook - Second Edition

Simon Riggs, GIANNI CIOLLI, Hannu Krosing, Gabriele Bartolini

Publisher Resources

ISBN: 9781788474924Supplemental Content