list databases with SQL command

Started by David Teranabout 21 years ago3 messagesgeneral
Jump to latest
#1David Teran
david.teran@cluster9.com

Hi,

maybe its a silly question, but is there a way to list all databases
with an SQL command? I know about the \l command from psql, but i
wonder if such things are possible with SQL.

regards, David

#2Peter Eisentraut
peter_e@gmx.net
In reply to: David Teran (#1)
Re: list databases with SQL command

Am Dienstag, 18. Januar 2005 11:32 schrieb David Teran:

maybe its a silly question, but is there a way to list all databases
with an SQL command? I know about the \l command from psql, but i
wonder if such things are possible with SQL.

SELECT * FROM pg_database;

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#3Richard Huxton
dev@archonet.com
In reply to: David Teran (#1)
Re: list databases with SQL command

David Teran wrote:

Hi,

maybe its a silly question, but is there a way to list all databases
with an SQL command? I know about the \l command from psql, but i wonder
if such things are possible with SQL.

Look into the pg_class table or the information schema.
Also, if you start psql with -E then you can see how it executes all its
backslash commands.

--
Richard Huxton
Archonet Ltd