Doug McNaught <doug@mcnaught.org> writes:
> Paul M Foster <paulf@quillandmouse.com> writes:
>> 3. Am I correct in assuming that you need to specify a database in order
>> to connect to PostgreSQL, and that, on a "virgin" system, template1 is
>> the database provided for that purpose? If it isn't necessary to specify
>> a database in order to connect, how would you otherwise do it?
> You are correct. The best practice is to stay out of template1 unless
> you are creating a new database or adding stuff to template1.
It's worth noting that there's a conflict between the use of template1
as the default template for CREATE DATABASE, versus its use as the
default database-to-connect-to for scripts like createuser. You could
get a failure from CREATE DATABASE if someone happens to be transiently
connected to template1 while creating a user or whatever.
This is a historical accident that arises from the fact that template1
is the only certain-to-exist database name (other than template0 which
is a recent innovation). We're probably going to have to change some
of this stuff eventually...
regards, tom lane