> As far as I know I must connect to *some*
> database, whose role is irrelevant, just so that I can execute "CREATE
> DATABASE ..." from that connection.
> I find this puzzling from a design perspective. Why involve some
> irrelevant DB in the process of creating a new one?
Because the backend can't operate without a set of system catalogs
to interrogate. We could maybe have a dummy database that had no
other purpose than to be connected to for specific commands ...
oh wait, that's pretty much what we do have.
> If so, what is the "canonical" database to connect to? (Is this the
> purpose of "template1"?)
Pre-8.1, that was the usual convention, but as of 8.1 we manufacture
an additional "standard" database named "postgres", and that's the
recommended connection target if you have no better alternative.
The reason for the change is that "template1" has the additional
function of being the default database-to-clone for CREATE DATABASE,
and there was too much conflict between those two uses.
regards, tom lane
In response to
pgsql-novice by date
|Next:||From: Robert Landsmeer||Date: 2006-05-15 06:42:49|
|Subject: Re: Wondering if anyone could help me |
|Previous:||From: Sean Davis||Date: 2006-05-15 00:40:57|
|Subject: Re: Q on requirement to connect to a specific DB|