Re: Q on requirement to connect to a specific DB

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Q on requirement to connect to a specific DB
Дата
Msg-id 17844.1147656688@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Q on requirement to connect to a specific DB  (<kynn@panix.com>)
Список pgsql-novice
<kynn@panix.com> writes:
> 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.

Correct.

> 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

В списке pgsql-novice по дате отправления:

Предыдущее
От: Sean Davis
Дата:
Сообщение: Re: Q on requirement to connect to a specific DB
Следующее
От: "Robert Landsmeer"
Дата:
Сообщение: Re: Wondering if anyone could help me