Thread

  1. Listing databases

    Doug Hall <doug_hall@aidt.edu> — 2004-05-05T21:20:29Z

    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
    
    
    
  2. Re: Listing databases

    scott.marlowe <scott.marlowe@ihs.com> — 2004-05-05T21:39:00Z

    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
    
    
    
    
    
  3. Re: Listing databases

    Joshua D. Drake <jd@commandprompt.com> — 2004-05-05T21:45:14Z

    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
    
  4. Re: Listing databases

    Mike Nolan <nolan@gw.tssi.com> — 2004-05-05T21:52:49Z

    > 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
    
    
    
  5. Re: Listing databases

    Alvaro Herrera <alvherre@dcc.uchile.cl> — 2004-05-05T21:58:23Z

    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)
    
    
  6. Re: Listing databases

    Adam Witney <awitney@sghms.ac.uk> — 2004-05-05T21:59:44Z

    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.
    
    
    
  7. Re: Listing databases

    Martijn van Oosterhout <kleptog@svana.org> — 2004-05-05T22:05:46Z

    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.
    
  8. Re: Listing databases

    Mark Harrison <mh@pixar.com> — 2004-05-05T22:07:35Z

    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
    
    
  9. Re: Listing databases

    Martin Marques <martin@bugs.unl.edu.ar> — 2004-05-05T22:14:44Z

    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
    -----------------------------------------------------------------