Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E25E8477229 for ; Fri, 24 Jan 2003 00:27:33 -0500 (EST) Received: from brasileiro.net (slxwy.dorms.usu.edu [129.123.227.56]) by postgresql.org (Postfix) with ESMTP id CD49D4762A9 for ; Thu, 23 Jan 2003 22:47:08 -0500 (EST) Received: from roberto by brasileiro.net with local (Exim 3.35 #1 (Debian)) id 18butV-00015Z-00; Thu, 23 Jan 2003 20:52:41 -0700 Date: Thu, 23 Jan 2003 20:52:41 -0700 From: Roberto Mello To: Kristopher Yates Cc: pgsql-sql@postgresql.org Subject: Re: SQL to list databases? Message-ID: <20030124035240.GA4123@cc.usu.edu> References: <81132473206F3A46A72BD6116E1A06AE1B14CC@black.aprote.com> <26610.1043341252@sss.pgh.pa.us> <3E303AF2.10603@cms-stl.com> <3E3051B3.8070007@grinz.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <3E3051B3.8070007@grinz.com> User-Agent: Mutt/1.4i X-message-flag: Please consider using an e-mail program other than Outlook. It's insecure. X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/381 X-Sequence-Number: 11246 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.