Re: Connect without specifying a database? - Mailing list pgsql-general

From John R Pierce
Subject Re: Connect without specifying a database?
Date
Msg-id 49E0CAC5.1070908@hogranch.com
Whole thread Raw
In response to Re: Connect without specifying a database?  ("lists@mgreg.com" <lists@mgreg.com>)
List pgsql-general
lists@mgreg.com wrote:
> I'm sorry, I'm confused by your reply.  I may have said "table" when I
> meant "database".  I believe it absolutely *does* make sense to
> connect without specifying a database first.  What if you hit that
> edge case where there are in fact no databases?  I suppose you could
> always run "createdb" just in case before you do anything else, but
> that seems counterintuitive.

that 'edge case' is one in which postgres isn't running.  you have to
run initdb to initialize the database cluster before you can start the
postmaster.  initdb creates template0, template1, and, in 8.x and newer,
postgres databases

the postgres database administrator account can do...

    $ psql -l

to list all databases, or...

    $ psql
    ....
    postgres=# \l

or, in sql, while connected to {template1 | template0 | postgres | ... }

    select datname,... from pg_catalog.pg_database;



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Connect without specifying a database?
Next
From: Tom Lane
Date:
Subject: Re: Connect without specifying a database?