Re: Multiple backend connections - Mailing list pgsql-general

From Doug McNaught
Subject Re: Multiple backend connections
Date
Msg-id m3k7et7fir.fsf@varsoon.wireboard.com
Whole thread Raw
In response to Multiple backend connections  (Paul M Foster <paulf@quillandmouse.com>)
Responses Re: Multiple backend connections  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Paul M Foster <paulf@quillandmouse.com> writes:

> Excuse my ignorance here.
>
> I'll summarize, and someone can tell me if I'm wrong.
>
> 1. So when you create a database, the system uses the open database
> you're connected to as a "template" unless you specify otherwise with a
> "WITH TEMPLATE = " clause?

No, it uses template1.

> 2. Since template0 does not accept connections, can I assume that it
> exists for the sole purpose of acting as a template for the creation of
> other databases?

template1 is the default template.  You can add types, PLs etc to it
and they will be copied to any other databases you create.

template0 is the 'virgin' template, for use if you mess up template1
or if you want to create a database without all the extra stuff you
put in template1.

> 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.

-Doug

pgsql-general by date:

Previous
From: Steve Crawford
Date:
Subject: Re: system table backup strategy
Next
From: Dennis Gearon
Date:
Subject: Re: system table backup strategy