Find Users in PostgreSQL
Question:Is there a query to run in PostgreSQL that will return all Users created?
Answer: In PostgreSQL, there is a system table called pg_user. You can run a query against this system table that returns all of the Users that have been created in PostgreSQL as well as information about these Users.
To retrieve all Users in PostgreSQL, you can execute the following SQL statement:
SELECT usename
FROM pg_user;
The pg_user table contains the following columns:
Column |
Explanation |
usename |
User name (ie: postgres, fastread.aitechtonic, etc) |
usesysid |
User ID (number assigned by PostgreSQL) |
usecreatedb |
Boolean value indicating whether user can create databases (t or f) |
usesuper |
Boolean value indicating whether user is a superuser (t or f) |
usecatupd |
Boolean value indicating whether user can update system catalogs (t or f) |
userepl |
Boolean value indicating whether user can initiate replication (t or f) |
passwd |
Password for user displayed as ******** |
valuntil |
Time when password will expire |
useconfig |
Session defaults for run-time configuration variables |