Hands-on Lab·PostgreSQL
PostgreSQL Roles and Attributes
PostgreSQL has one object where other databases have two: a role is a user when it can log in and a group when it cannot. The LOGIN attribute is the only difference.
Roles and Authentication Guide 16 of 47 Beginner
- OSUbuntu 26.04 LTS
- PostgreSQL18.6-0ubuntu0.26.04.1
- Authscram-sha-256
- TimeAbout 13 min
CREATE USER still exists and is exactly CREATE ROLE ... LOGIN. The two-word distinction in older documentation describes syntax, not two kinds of object.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
This guide includes
Use this because PostgreSQL has one object where other databases have two. This matters because a role is a user when it can log in and a group when it cannot - and the LOGIN attribute is the entire difference.
- listing roles and their attributes with
\du - reading the same thing from
pg_roles, which is the queryable form - trying to log in as a role with no LOGIN attribute, and being refused
Before you start
- A superuser connection -
sudo -u postgres psql.
-
List the roles and read their attributes
-
Read the same thing from the catalogue
-
Try to log in as a role that cannot