principal limitation is that no other sessions can be connected to
the template database while it is being copied. <command>CREATE
DATABASE</command> will fail if any other connection exists when it starts;
otherwise, new connections to the template database are locked out
until <command>CREATE DATABASE</command> completes.
See <xref linkend="manage-ag-templatedbs"/> for more information.
</para>
<para>
The character set encoding specified for the new database must be
compatible with the chosen locale settings (<literal>LC_COLLATE</literal> and
<literal>LC_CTYPE</literal>). If the locale is <literal>C</literal> (or equivalently
<literal>POSIX</literal>), then all encodings are allowed, but for other
locale settings there is only one encoding that will work properly.
(On Windows, however, UTF-8 encoding can be used with any locale.)
<command>CREATE DATABASE</command> will allow superusers to specify
<literal>SQL_ASCII</literal> encoding regardless of the locale settings,
but this choice is deprecated and may result in misbehavior of
character-string functions if data that is not encoding-compatible
with the locale is stored in the database.
</para>
<para>
The encoding and locale settings must match those of the template database,
except when <literal>template0</literal> is used as template. This is because
other databases might contain data that does not match the specified
encoding, or might contain indexes whose sort ordering is affected by
<literal>LC_COLLATE</literal> and <literal>LC_CTYPE</literal>. Copying such data would
result in a database that is corrupt according to the new settings.
<literal>template0</literal>, however, is known to not contain any data or
indexes that would be affected.
</para>
<para>
There is currently no option to use a database locale with nondeterministic
comparisons (see <link linkend="sql-createcollation"><command>CREATE
COLLATION</command></link> for an explanation). If this is needed, then
per-column collations would need to be used.
</para>
<para>
The <literal>CONNECTION LIMIT</literal>