You can use the information_schema.users view to return information about users. You can use a SELECT query to return information about each user, as shown in the example below.

To view information about users, you must have user privilege or ownership of the user object.

SELECT
  *
FROM
  information_schema.users;

For more information, see Managing users.

Columns in information_schema.users

Each row has the following columns with information about each user.

Column NameData TypeDescription
user_nameTEXTThe name of the user.
login_nameTEXTThe name of the login linked to the user. Empty if the login is linked to a service account.
service_account_nameTEXTThe name of the service account linked to the user. Empty if the login is linked to a service account.
default_databaseTEXTThe default database set for the user.
default_schemaTEXTThe default schema set for the user.
default_engineTEXTThe default engine set for the user.
createdTIMESTAMPTZTime the user was created.
user_ownerTEXTThe name of the user who created the user.
last_alteredTIMESTAMPTZTime the user was last altered.
last_altered_byTEXTThe name of the last user to edit the user.