471,092 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

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.

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

Nov 23 '05 #1
16 2051
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 ma*******@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
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #2
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 ma*******@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
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #3
> 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
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #4
> 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
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #5

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 ma*******@postgresql.org)

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #6

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 ma*******@postgresql.org)

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #7
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 <kl*****@svana.org> http://svana.org/kleptog/ 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.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFAmWU6Y5Twig3Ge+YRAj1WAJ41k4ZioskqZpiF0Khkj1 Jg8343nwCeJwlu
gEEi0hnbjEEr8JXAJ5TkyTE=
=zxsd
-----END PGP SIGNATURE-----

Nov 23 '05 #8
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 <kl*****@svana.org> http://svana.org/kleptog/ 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.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFAmWU6Y5Twig3Ge+YRAj1WAJ41k4ZioskqZpiF0Khkj1 Jg8343nwCeJwlu
gEEi0hnbjEEr8JXAJ5TkyTE=
=zxsd
-----END PGP SIGNATURE-----

Nov 23 '05 #9
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

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

Nov 23 '05 #10
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

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

Nov 23 '05 #11
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)

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #12
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)

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #13
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


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #14
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


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #15
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
-----------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #16
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
-----------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Chris | last post: by
19 posts views Thread by SU News Server | last post: by
3 posts views Thread by David Jacques | last post: by
3 posts views Thread by John Barr | last post: by
2 posts views Thread by Daniel Groh | last post: by
2 posts views Thread by Terry Olsen | last post: by
1 post views Thread by Johnny Jörgensen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.