Listing databases

Started by Doug Hallalmost 22 years ago9 messagesgeneral
Jump to latest
#1Doug Hall
Doug_Hall@aidt.edu

Sorry for the newbie question, but how do you get PostgreSQL to list
the available databases? I know how to log into a certain database, but
not list all of them. I know this must be possible because the
phppgAdmin web site demonstrates it with their trial server.

Thanks,
Doug Hall

#2scott.marlowe
scott.marlowe@ihs.com
In reply to: Doug Hall (#1)
Re: Listing databases

On Wed, 5 May 2004, Doug Hall wrote:

Sorry for the newbie question, but how do you get PostgreSQL to list
the available databases? I know how to log into a certain database, but
not list all of them. I know this must be possible because the
phppgAdmin web site demonstrates it with their trial server.

Assuming you're in psql just do:

\l

#3Joshua D. Drake
jd@commandprompt.com
In reply to: Doug Hall (#1)
Re: Listing databases

Doug Hall wrote:

Sorry for the newbie question, but how do you get PostgreSQL to list the
available databases? I know how to log into a certain database, but not
list all of them. I know this must be possible because the phppgAdmin
web site demonstrates it with their trial server.

select * from pg_database;

Thanks,
Doug Hall

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

-- 
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL
#4Mike Nolan
nolan@gw.tssi.com
In reply to: Doug Hall (#1)
Re: Listing databases

Sorry for the newbie question, but how do you get PostgreSQL to list
the available databases? I know how to log into a certain database, but
not list all of them. I know this must be possible because the
phppgAdmin web site demonstrates it with their trial server.

Use the \l command within psql.
--
Mike Nolan

#5Alvaro Herrera
alvherre@dcc.uchile.cl
In reply to: Doug Hall (#1)
Re: Listing databases

On Wed, May 05, 2004 at 04:20:29PM -0500, Doug Hall wrote:

Sorry for the newbie question, but how do you get PostgreSQL to list
the available databases? I know how to log into a certain database, but
not list all of them. I know this must be possible because the
phppgAdmin web site demonstrates it with their trial server.

With psql, you can use
psql -l

Else see the pg_database table.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"En las profundidades de nuestro inconsciente hay una obsesiva necesidad
de un universo l�gico y coherente. Pero el universo real se halla siempre
un paso m�s all� de la l�gica" (Irulan)

#6Adam Witney
awitney@sghms.ac.uk
In reply to: Doug Hall (#1)
Re: Listing databases

If you attach with psql then just use \l

Or this works as well

SELECT datname from pg_database;

Sorry for the newbie question, but how do you get PostgreSQL to list
the available databases? I know how to log into a certain database, but
not list all of them. I know this must be possible because the
phppgAdmin web site demonstrates it with their trial server.

Thanks,
Doug Hall

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

#7Martijn van Oosterhout
kleptog@svana.org
In reply to: Doug Hall (#1)
Re: Listing databases

On Wed, May 05, 2004 at 04:20:29PM -0500, Doug Hall wrote:

Sorry for the newbie question, but how do you get PostgreSQL to list
the available databases? I know how to log into a certain database, but
not list all of them. I know this must be possible because the
phppgAdmin web site demonstrates it with their trial server.

psql -l

--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.

#8Mark Harrison
mh@pixar.com
In reply to: Doug Hall (#1)
Re: Listing databases

Doug Hall wrote:

Sorry for the newbie question, but how do you get PostgreSQL to list the
available databases? I know how to log into a certain database, but not
list all of them. I know this must be possible because the phppgAdmin
web site demonstrates it with their trial server.

Thanks,
Doug Hall

Try \? in psql, it will show some really nice commands. \d will show you the
tables, and "\d tablename" will describe the table.

Try \dS and friends to see the system tables.

One of the best ways to see what is going on under the covers to to
run psql --echo-hidden:

--echo-hidden
Echoes the actual queries generated by \d and other
backslash commands. You can use this if you wish to
include similar functionality into your own pro�
grams. This is equivalent to setting the variable
ECHO_HIDDEN from within psql.

Whoever thought to add this to psql is a genius!!!

HTH...
Mark

--
Mark Harrison
Pixar Animation Studios

#9Martín Marqués
martin@bugs.unl.edu.ar
In reply to: Mike Nolan (#4)
Re: Listing databases

El Mié 05 May 2004 18:52, Mike Nolan escribió:

Sorry for the newbie question, but how do you get PostgreSQL to list
the available databases? I know how to log into a certain database, but
not list all of them. I know this must be possible because the
phppgAdmin web site demonstrates it with their trial server.

Use the \l command within psql.

I guess "psql -l" is better, so you can then choose the DB. :-)

--
19:10:02 up 7 days, 32 min, 1 user, load average: 0.60, 1.02, 1.38
-----------------------------------------------------------------
Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------