Re: Connect without specifying a database?

From: John R Pierce <pierce(at)hogranch(dot)com>
To: "lists(at)mgreg(dot)com" <lists(at)mgreg(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Connect without specifying a database?
Date: 2009-04-11 16:52:21
Message-ID: 49E0CAC5.1070908@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

lists(at)mgreg(dot)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;

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-04-11 16:56:32 Re: Connect without specifying a database?
Previous Message Tom Lane 2009-04-11 16:50:22 Re: Connect without specifying a database?