Обсуждение: Listing databases

Поиск
Список
Период
Сортировка

Listing databases

От
Doug Hall
Дата:
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


Re: Listing databases

От
"scott.marlowe"
Дата:
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




Re: Listing databases

От
"Joshua D. Drake"
Дата:
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

Вложения

Re: Listing databases

От
Mike Nolan
Дата:
> 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


Re: Listing databases

От
Alvaro Herrera
Дата:
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)

Re: Listing databases

От
Adam Witney
Дата:
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.


Re: Listing databases

От
Martijn van Oosterhout
Дата:
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/
> 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.

Вложения

Re: Listing databases

От
Mark Harrison
Дата:
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

Re: Listing databases

От
Martin Marques
Дата:
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
-----------------------------------------------------------------