From: | Roberto Mello <rmello(at)cc(dot)usu(dot)edu> |
---|---|
To: | Kristopher Yates <kris(at)grinz(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: SQL to list databases? |
Date: | 2003-01-24 03:52:41 |
Message-ID: | 20030124035240.GA4123@cc.usu.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, Jan 23, 2003 at 02:33:55PM -0600, Kristopher Yates wrote:
> I have been wondering the same thing..
SELECT * FROM pg_databases ?
> >Is there a query that will return all the databases available, similar
> >to what psql -l does?
The handy "-E" flag to psql helps:
roberto(at)brasileiro:~$ psql -E -l
********* QUERY **********
SELECT d.datname as "Name",
u.usename as "Owner",
pg_encoding_to_char(d.encoding) as "Encoding"
FROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid
ORDER BY 1;
**************************
List of databases
Name | Owner | Encoding
----------------+------------+----------
addresses | windozefoo | LATIN1
foobar | roberto | LATIN1
openacs-4 | roberto | LATIN1
template0 | postgres | LATIN1
template1 | postgres | LATIN1
-Roberto
--
+----| Roberto Mello - http://www.brasileiro.net/ |------+
+ Computer Science Graduate Student, Utah State University +
+ USU Free Software & GNU/Linux Club - http://fslc.usu.edu/ +
Dente lupus, cornu taurus petit.
From | Date | Subject | |
---|---|---|---|
Next Message | Roberto Mello | 2003-01-24 05:06:55 | Re: Scheduling Events? |
Previous Message | codeWarrior | 2003-01-24 03:47:24 | Re: Rename database? |