List users in Redshift

Query below returns list of users in current database.

Do you ever feel like him?

Don't worry, we just might have a solution...

Find out what it is

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.

sample results

Create beautiful and useful documentation of your Redshift

Generate convenient documentation of your databases in minutes and share it with your team. Capture and preserve tribal knowledge in shared repository.

See how it works