1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-29 13:56:47 +03:00

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
This commit is contained in:
Tom Lane 2021-11-02 12:54:35 -04:00
parent af8c580e5c
commit 7d9ec0754a
3 changed files with 25 additions and 16 deletions

View File

@ -136,15 +136,21 @@ CREATE DATABASE <replaceable>name</replaceable>;
</para> </para>
<para> <para>
A second database, Two additional databases,
<literal>template1</literal>,<indexterm><primary>template1</primary></indexterm> <literal>template1</literal><indexterm><primary>template1</primary></indexterm>
is also created during database cluster initialization. Whenever a and
<literal>template0</literal>,<indexterm><primary>template0</primary></indexterm>
are also created during database cluster initialization. Whenever a
new database is created within the new database is created within the
cluster, <literal>template1</literal> is essentially cloned. cluster, <literal>template1</literal> is essentially cloned.
This means that any changes you make in <literal>template1</literal> are This means that any changes you make in <literal>template1</literal> are
propagated to all subsequently created databases. Because of this, propagated to all subsequently created databases. Because of this,
avoid creating objects in <literal>template1</literal> unless you want them avoid creating objects in <literal>template1</literal> unless you want them
propagated to every newly created database. More details propagated to every newly created database.
<literal>template0</literal> is meant as a pristine copy of the original
contents of <literal>template1</literal>. It can be cloned instead
of <literal>template1</literal> when it is important to make a database
without any such site-local additions. More details
appear in <xref linkend="manage-ag-templatedbs"/>. appear in <xref linkend="manage-ag-templatedbs"/>.
</para> </para>

View File

@ -46,13 +46,16 @@ PostgreSQL documentation
Creating a database cluster consists of creating the directories in Creating a database cluster consists of creating the directories in
which the database data will live, generating the shared catalog which the database data will live, generating the shared catalog
tables (tables that belong to the whole cluster rather than to any tables (tables that belong to the whole cluster rather than to any
particular database), and creating the <literal>template1</literal> particular database), and creating the <literal>postgres</literal>,
and <literal>postgres</literal> databases. When you later create a <literal>template1</literal>, and <literal>template0</literal> databases.
new database, everything in the <literal>template1</literal> database is
copied. (Therefore, anything installed in <literal>template1</literal>
is automatically copied into each database created later.)
The <literal>postgres</literal> database is a default database meant The <literal>postgres</literal> database is a default database meant
for use by users, utilities and third party applications. for use by users, utilities and third party applications.
<literal>template1</literal> and <literal>template0</literal> are
meant as source databases to be copied by later <command>CREATE
DATABASE</command> commands. <literal>template0</literal> should never
be modified, but you can add objects to <literal>template1</literal>,
which by default will be copied into databases created later. See
<xref linkend="manage-ag-templatedbs"/> for more details.
</para> </para>
<para> <para>
@ -88,7 +91,7 @@ PostgreSQL documentation
collation order (<literal>LC_COLLATE</literal>) and character set classes collation order (<literal>LC_COLLATE</literal>) and character set classes
(<literal>LC_CTYPE</literal>, e.g., upper, lower, digit) can be set separately (<literal>LC_CTYPE</literal>, e.g., upper, lower, digit) can be set separately
for a database when it is created. <command>initdb</command> determines for a database when it is created. <command>initdb</command> determines
those settings for the <literal>template1</literal> database, which will those settings for the template databases, which will
serve as the default for all other databases. serve as the default for all other databases.
</para> </para>
@ -184,9 +187,9 @@ PostgreSQL documentation
<term><option>--encoding=<replaceable class="parameter">encoding</replaceable></option></term> <term><option>--encoding=<replaceable class="parameter">encoding</replaceable></option></term>
<listitem> <listitem>
<para> <para>
Selects the encoding of the template database. This will also Selects the encoding of the template databases. This will also
be the default encoding of any database you create later, be the default encoding of any database you create later,
unless you override it there. The default is derived from the locale, or unless you override it then. The default is derived from the locale, or
<literal>SQL_ASCII</literal> if that does not work. The character sets supported by <literal>SQL_ASCII</literal> if that does not work. The character sets supported by
the <productname>PostgreSQL</productname> server are described the <productname>PostgreSQL</productname> server are described
in <xref linkend="multibyte-charset-supported"/>. in <xref linkend="multibyte-charset-supported"/>.

View File

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