Skip to content

Commit 7d9ec07

Browse files
committed
Doc: clean up some places that mentioned template1 but not template0.
Improve old text that wasn't updated when we added template0 to the standard database set. Per suggestion from P. Luzanov. Discussion: https://postgr.es/m/163583775122.675.3700595100340939507@wrigleys.postgresql.org
1 parent af8c580 commit 7d9ec07

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

doc/src/sgml/manage-ag.sgml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,21 @@ CREATE DATABASE <replaceable>name</replaceable>;
136136
</para>
137137

138138
<para>
139-
A second database,
140-
<literal>template1</literal>,<indexterm><primary>template1</primary></indexterm>
141-
is also created during database cluster initialization. Whenever a
139+
Two additional databases,
140+
<literal>template1</literal><indexterm><primary>template1</primary></indexterm>
141+
and
142+
<literal>template0</literal>,<indexterm><primary>template0</primary></indexterm>
143+
are also created during database cluster initialization. Whenever a
142144
new database is created within the
143145
cluster, <literal>template1</literal> is essentially cloned.
144146
This means that any changes you make in <literal>template1</literal> are
145147
propagated to all subsequently created databases. Because of this,
146148
avoid creating objects in <literal>template1</literal> unless you want them
147-
propagated to every newly created database. More details
149+
propagated to every newly created database.
150+
<literal>template0</literal> is meant as a pristine copy of the original
151+
contents of <literal>template1</literal>. It can be cloned instead
152+
of <literal>template1</literal> when it is important to make a database
153+
without any such site-local additions. More details
148154
appear in <xref linkend="manage-ag-templatedbs"/>.
149155
</para>
150156

doc/src/sgml/ref/initdb.sgml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,16 @@ PostgreSQL documentation
4646
Creating a database cluster consists of creating the directories in
4747
which the database data will live, generating the shared catalog
4848
tables (tables that belong to the whole cluster rather than to any
49-
particular database), and creating the <literal>template1</literal>
50-
and <literal>postgres</literal> databases. When you later create a
51-
new database, everything in the <literal>template1</literal> database is
52-
copied. (Therefore, anything installed in <literal>template1</literal>
53-
is automatically copied into each database created later.)
49+
particular database), and creating the <literal>postgres</literal>,
50+
<literal>template1</literal>, and <literal>template0</literal> databases.
5451
The <literal>postgres</literal> database is a default database meant
5552
for use by users, utilities and third party applications.
53+
<literal>template1</literal> and <literal>template0</literal> are
54+
meant as source databases to be copied by later <command>CREATE
55+
DATABASE</command> commands. <literal>template0</literal> should never
56+
be modified, but you can add objects to <literal>template1</literal>,
57+
which by default will be copied into databases created later. See
58+
<xref linkend="manage-ag-templatedbs"/> for more details.
5659
</para>
5760

5861
<para>
@@ -88,7 +91,7 @@ PostgreSQL documentation
8891
collation order (<literal>LC_COLLATE</literal>) and character set classes
8992
(<literal>LC_CTYPE</literal>, e.g., upper, lower, digit) can be set separately
9093
for a database when it is created. <command>initdb</command> determines
91-
those settings for the <literal>template1</literal> database, which will
94+
those settings for the template databases, which will
9295
serve as the default for all other databases.
9396
</para>
9497

@@ -184,9 +187,9 @@ PostgreSQL documentation
184187
<term><option>--encoding=<replaceable class="parameter">encoding</replaceable></option></term>
185188
<listitem>
186189
<para>
187-
Selects the encoding of the template database. This will also
190+
Selects the encoding of the template databases. This will also
188191
be the default encoding of any database you create later,
189-
unless you override it there. The default is derived from the locale, or
192+
unless you override it then. The default is derived from the locale, or
190193
<literal>SQL_ASCII</literal> if that does not work. The character sets supported by
191194
the <productname>PostgreSQL</productname> server are described
192195
in <xref linkend="multibyte-charset-supported"/>.

doc/src/sgml/runtime.sgml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474
which is meant as a default database for use by utilities, users and third
7575
party applications. The database server itself does not require the
7676
<literal>postgres</literal> database to exist, but many external utility
77-
programs assume it exists. Another database created within each cluster
78-
during initialization is called
79-
<literal>template1</literal>. As the name suggests, this will be used
80-
as a template for subsequently created databases; it should not be
77+
programs assume it exists. There are two more databases created within
78+
each cluster during initialization, named <literal>template1</literal>
79+
and <literal>template0</literal>. As the names suggest, these will be
80+
used as templates for subsequently-created databases; they should not be
8181
used for actual work. (See <xref linkend="managing-databases"/> for
8282
information about creating new databases within a cluster.)
8383
</para>

0 commit comments

Comments
 (0)