In PostgreSQL, a login role is a role with the LOGIN attribute, allowing it to connect to the database. A group role does not have LOGIN and is used to group privileges and manage permissions collectively.
SELECT rolname FROM pg_roles WHERE rolcanlogin = true ORDER BY rolname;
The column rolcanlogin in pg_roles indicates if a role can log in. Filtering by rolcanlogin = true returns only login roles.
Group roles are created with NOLOGIN. To assign login roles as members, you grant the login roles TO the group role, not the other way around.
pg_auth_members links roles and members by OIDs. roleid is the group role, member is the login role. Joining pg_roles twice allows filtering by names.
SELECT * FROM pg_auth_members WHERE roleid = (SELECT oid FROM pg_roles WHERE rolname = 'dave') AND member = (SELECT oid FROM pg_roles WHERE rolname = 'admins');
In pg_auth_members, roleid is the group role's OID and member is the login role's OID. The query reverses these, so it finds no matches.