Re: How to list databases with SQL statement?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Marian D Marinov <hackman(at)hydra(dot)azilian(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to list databases with SQL statement?
Date: 2004-11-23 04:56:40
Message-ID: 20041123045640.GA22766@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John DeSoi 2004-11-23 05:10:05 Re: How to list databases with SQL statement?
Previous Message Quinton Delpeche 2004-11-23 04:52:40 Re: How to list databases with SQL statement?