Search Postgresql Archives

Re: user/groups query ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you very much !

----- Original Message ----- From: "John DeSoi" <desoi@xxxxxxxxxx>
To: "Zlatko Matić" <zlatko.matic1@xxxxxxxxxxx>
Cc: <pgsql-general@xxxxxxxxxxxxxx>
Sent: Monday, June 20, 2005 3:40 AM
Subject: Re:  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

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux