kuda.ai

Thoughts on programming and music theory.

Postgres: Users And Groups Are Roles

Created on April 6, 2025
Updated on April 7, 2025
postgres

In Postgres, there are no users and no groups, just roles.

You can still distinguish the two, however.

When you create a role, you can specify WITH login (Users) or WITH nologin (Groups).

-- Groups:
CREATE ROLE developer WITH nologin;
CREATE ROLE app WITH nologin;

-- Users:
CREATE ROLE dev WITH login PASSWORD 'pa55word' INHERIT;
GRANT developer TO dev;

CREATE ROLE kuda_ai WITH login PASSWORD 'pa55word' INHERIT;
GRANT app TO kuda_ai;