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> option is only enforced approximately;
if two new sessions start at about the same time when just one
connection <quote>slot</quote> remains for the database, it is possible that
both will fail. Also, the limit is not enforced against superusers or
background worker processes.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
To create a new database:
<programlisting>
CREATE DATABASE lusiadas;
</programlisting>
</para>
<para>
To create a database <literal>sales</literal> owned by user <literal>salesapp</literal>
with a default tablespace of <literal>salesspace</literal>:
<programlisting>
CREATE DATABASE sales OWNER salesapp TABLESPACE salesspace;
</programlisting>
</para>
<para>
To create a database <literal>music</literal> with a different locale:
<programlisting>
CREATE DATABASE music
LOCALE 'sv_SE.utf8'
TEMPLATE template0;
</programlisting>
In this example, the <literal>TEMPLATE template0</literal> clause is required if
the specified locale is different from the one in <literal>template1</literal>.
(If it is not, then specifying the locale explicitly is redundant.)
</para>
<para>
To create a database <literal>music2</literal> with a different locale and a
different character set encoding:
<programlisting>
CREATE DATABASE music2
LOCALE 'sv_SE.iso885915'
ENCODING LATIN9
TEMPLATE template0;
</programlisting>
The specified locale and encoding settings must match, or an error will be
reported.
</para>
<para>
Note that locale names are specific to the operating system, so that the
above commands might not work in the same way everywhere.
</para>
</refsect1>
<refsect1>
<title>Compatibility</title>
<para>
There is no <command>CREATE DATABASE</command> statement in the SQL
standard. Databases are equivalent to catalogs, whose creation is
implementation-defined.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-alterdatabase"/></member>
<member><xref linkend="sql-dropdatabase"/></member>
</simplelist>
</refsect1>
</refentry>