Thank you very much !
----- Original Message -----
From: "John DeSoi" <desoi@pgedit.com>
To: "Zlatko Matić" <zlatko.matic1@sb.t-com.hr>
Cc: <pgsql-general@postgresql.org>
Sent: Monday, June 20, 2005 3:40 AM
Subject: Re: [GENERAL] user/groups query ?
On Jun 19, 2005, at 3:56 PM, Zlatko Matić wrote:
>
> How to make a query that will include information both about user and
> group (or groups) he belongs to ?
> Thanks.
Turning on the ECHO_HIDDEN feature in psql shows how to do this.
\set ECHO_HIDDEN 1
\du user1
********* QUERY **********
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",
ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid =
ANY(g.grolist)) as "Groups"
FROM pg_catalog.pg_user u
WHERE u.usename ~ '^user1$'
ORDER BY 1;
**************************
List of users
User name | User ID | Attributes | Groups
-----------+---------+------------+--------
user1 | 100 | | {test}
(1 row)
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org