Query below returns list of users in current database.
Query
select usesysid as user_id,
usename as username,
usecreatedb as db_create,
usesuper as is_superuser,
valuntil as password_expiration
from pg_user
order by user_id
Columns
- user_id - id of the user
- username - user name
- db_create - flag indicating if user can create new databases
- is_superuser - flag if user have superuser privileges
- password_expiration - date of user password expiration
Rows
- One row represents one user in the database
- Scope of rows: all users in the database
- Ordered by user id
Sample results
Those results show that there are 4 users in current database.