Junior — Middle
How does PostgreSQL implement roles when creating a new user?
sobes.tech AI
Answer from AI
In PostgreSQL, the concepts of "user" and "role" are combined: a user is a role with login capability (LOGIN).
When creating a new user using the CREATE USER command, a role with the LOGIN attribute is actually created. This means that a user is a special case of a role that has authentication rights.
Example:
CREATE USER username WITH PASSWORD 'password';
Equivalent to:
CREATE ROLE username WITH LOGIN PASSWORD 'password';
Thus, PostgreSQL uses a single role system for access management, where roles can be both permission groups and users if they have login rights.