Обсуждение: How to list user accounts?

Поиск
Список
Период
Сортировка

How to list user accounts?

От
Thanh Q Lam
Дата:
Hi,

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


Thanks,
Thanh


Re: How to list user accounts?

От
Bruno Wolff III
Дата:
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?

От
Scott Marlowe
Дата:
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?

От
Michael Fuhr
Дата:
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/