Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Pretty cut and dry, I am just a total noob. Is there a way to make a given role inherit from another?

share|improve this question

1 Answer 1

up vote 1 down vote accepted
CREATE ROLE doe LOGIN INHERIT;
CREATE ROLE sales NOINHERIT;
CREATE ROLE marketing NOINHERIT;
GRANT sales to doe;
GRANT marketing to sales;

If you connect to PostgreSQL as doe, you will have privileges of doe plus privileges granted to sales, because doe user role has INHERIT attribute. However, you do not have privileges of marketing because the NOINHERIT attribute is defined for the sales user role.

Note: The role attributes LOGIN, SUPERUSER, CREATEDB, and CREATEROLE can be thought of as special privileges, but they are never inherited as ordinary privileges on database objects are.

share|improve this answer
    
The purpose of NOINHERIT is that you still have the right to SET ROLE sales; and then act as the sales role, but you must do so explicitly. So it's good for granting rights that should only be exersized intentionally, kind of like "sudo". –  Craig Ringer Mar 15 at 0:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.