amazon-redshiftHow do I list users on Amazon Redshift?
To list users on Amazon Redshift, you can use the pg_user
system view. This view contains information about all users that have been created in the current database.
Example
SELECT usename, usesysid, usecreatedb, usesuper, valuntil
FROM pg_user;
Output example
usename | usesysid | usecreatedb | usesuper | valuntil
---------+----------+-------------+----------+----------
user1 | 10 | t | t |
user2 | 11 | t | f |
user3 | 12 | f | f |
The code above will list all the users in the current database, along with their system ID, their ability to create databases, their ability to use superuser privileges, and the expiration date of their account.
Code explanation
-
SELECT usename, usesysid, usecreatedb, usesuper, valuntil
: This is the SELECT statement that will retrieve the list of users in the current database. The columns specified in this statement are the username, system ID, ability to create databases, ability to use superuser privileges, and expiration date of the account. -
FROM pg_user
: This is the FROM clause that specifies the source of the data, which is thepg_user
system view.
Helpful links
More of Amazon Redshift
- How can I handle divide by zero errors when using Amazon Redshift?
- How can I use Amazon Redshift UNION to combine data from multiple tables?
- How do I extract JSON data from Amazon Redshift?
- How do I use Amazon Redshift's UNLOAD command?
- How do I convert an Amazon Redshift timestamp to a date?
- How can I transfer data from Amazon Redshift to an Amazon S3 bucket?
- How do I use the Amazon Redshift YEAR function?
- How can I calculate the serverless pricing for Amazon Redshift?
- How do I use Amazon Redshift RSQL to query data?
- How do I use regular expressions with Amazon Redshift?
See more codes...