I want to get a list of users for a certain database in psql - for example "template0". Who are the users? Or for "template1" database: - who are the users there?
Already tried:
\du+ -- no database is Listed not Users Select * from "pg_users"; -- no database is listed
SELECT rolname FROM pg_roles; The psql program's \du meta-command is also useful for listing the existing roles. In order to bootstrap the database system, a freshly initialized system always contains one predefined role.
User Data in PostgreSQL All the user-related data is stored in the table named pg_user, which belongs to the schema named pg_catalog.
Users own database objects (for example, tables) and can assign privileges on those objects to other users to control who has access to which object. This chapter describes how to create and manage users and introduces the privilege system.
User aren't actually, "for the database", they're for cluster and are given different permissions to access databases. To list users \du
should do, but you need to be connected. Something like
psql template1 -c '\du'
from the command line prompt should do. (or \du
from psql prompt when you are connected to the database).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With