pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roberto Mello <rmello@cc.usu.edu>
To: Kristopher Yates <kris@grinz.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: SQL to list databases?
Date: Thu, 23 Jan 2003 20:52:41 -0700
Message-ID: <20030124035240.GA4123@cc.usu.edu> (raw)
In-Reply-To: <3E3051B3.8070007@grinz.com>
References: <81132473206F3A46A72BD6116E1A06AE1B14CC@black.aprote.com>
	<26610.1043341252@sss.pgh.pa.us>
	<3E303AF2.10603@cms-stl.com>
	<3E3051B3.8070007@grinz.com>

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@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.



view thread (8+ messages)  latest in thread

Message-ID: <20030124035240.GA4123@cc.usu.edu>
Permalink:  ../20030124035240.GA4123@cc.usu.edu/
Also on:    postgresql.org/message-id/20030124035240.GA4123@cc.usu.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rmello@cc.usu.edu, kris@grinz.com
  Subject: Re: SQL to list databases?
  In-Reply-To: <20030124035240.GA4123@cc.usu.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox