Re: Connect without specifying a database?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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:56:32
Message-ID: 25459.1239468992@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

[ forgot to respond to this bit... ]

"lists(at)mgreg(dot)com" <lists(at)mgreg(dot)com> writes:
> What if you hit that edge case where there are in fact no databases?

There is no such edge case. DROP DATABASE has to be issued while
connected to some database, and it won't let you drop the DB you're
connected to.

> I suppose you could
> always run "createdb" just in case before you do anything else, but
> that seems counterintuitive.

And CREATE DATABASE has to be issued while connected to some database,
so createdb still has to have a default database to connect to. There
really is no state in Postgres corresponding to "connected but not
connected to any particular database".

It does all hang together. You will need to lose a lot of MySQL
preconceptions along the way, I fear.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message lists@mgreg.com 2009-04-11 17:15:44 Re: Connect without specifying a database?
Previous Message John R Pierce 2009-04-11 16:52:21 Re: Connect without specifying a database?