Thread: How to list user accounts?

How to list user accounts?

From
Thanh Q Lam
Date:
Hi,

Is there a command/option to list all database user accounts in postgres?


Thanks,
Thanh


Re: How to list user accounts?

From
Bruno Wolff III
Date:
On Tue, Jul 12, 2005 at 14:59:27 -0400,
  Thanh Q Lam <thanh.q.lam@alcatel.com> wrote:
>
> Is there a command/option to list all database user accounts in postgres?

select usename from pg_user;

Re: How to list user accounts?

From
Scott Marlowe
Date:
On Tue, 2005-07-12 at 13:59, Thanh Q Lam wrote:
> Hi,
>
> Is there a command/option to list all database user accounts in postgres?

From the psql monitor:

\du

via sql:

SELECT u.usename AS "User name",
  u.usesysid AS "User ID",
  CASE WHEN u.usesuper AND u.usecreatedb THEN CAST('superuser, create
database' AS pg_catalog.text)
       WHEN u.usesuper THEN CAST('superuser' AS pg_catalog.text)
       WHEN u.usecreatedb THEN CAST('create database' AS
pg_catalog.text)
       ELSE CAST('' AS pg_catalog.text)
  END AS "Attributes"
FROM pg_catalog.pg_user u
ORDER BY 1;

(what psql does behind the scenes when you type \du)

Re: How to list user accounts?

From
Michael Fuhr
Date:
On Tue, Jul 12, 2005 at 02:59:27PM -0400, Thanh Q Lam wrote:
>
> Is there a command/option to list all database user accounts in postgres?

If you're using psql then see "Meta-Commands" in the psql documentation;
otherwise see your client's documentation.  You could also query
the system catalogs directly.

http://www.postgresql.org/docs/8.0/static/app-psql.html
http://www.postgresql.org/docs/8.0/static/catalogs.html

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/