Re: How to list databases with SQL statement? - Mailing list pgsql-general

From Michael Fuhr
Subject Re: How to list databases with SQL statement?
Date
Msg-id 20041123045640.GA22766@winnie.fuhr.org
Whole thread Raw
In response to How to list databases with SQL statement?  (Marian D Marinov <hackman@hydra.azilian.net>)
List pgsql-general
On Sat, Nov 20, 2004 at 12:39:38AM +0000, Marian D Marinov wrote:

> Is there a way to list all databases which belong to the current user with an
> SQL query?

Such information is in the system catalogs:

http://www.postgresql.org/docs/7.4/static/catalogs.html

If you run psql with the -E option, you can see the queries that
psql makes when you issue commands like \l to show the list of
databases and their owners.  You can then copy those queries and
modify them to meet your needs.

The name of the current user is available as CURRENT_USER and
SESSION_USER -- see the Miscellaneous Functions documentation for
the difference:

http://www.postgresql.org/docs/7.4/static/functions-misc.html

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

pgsql-general by date:

Previous
From: Quinton Delpeche
Date:
Subject: Re: How to list databases with SQL statement?
Next
From: John DeSoi
Date:
Subject: Re: How to list databases with SQL statement?