system vendor and what was installed. On most Unix systems, the command
<literal>locale -a</literal> will provide a list of available locales.
Windows uses more verbose locale names, such as <literal>German_Germany</literal>
or <literal>Swedish_Sweden.1252</literal>, but the principles are the same.
</para>
<para>
Occasionally it is useful to mix rules from several locales, e.g.,
use English collation rules but Spanish messages. To support that, a
set of locale subcategories exist that control only certain
aspects of the localization rules:
<informaltable>
<tgroup cols="2">
<colspec colname="col1" colwidth="1*"/>
<colspec colname="col2" colwidth="3*"/>
<tbody>
<row>
<entry><envar>LC_COLLATE</envar></entry>
<entry>String sort order</entry>
</row>
<row>
<entry><envar>LC_CTYPE</envar></entry>
<entry>Character classification (What is a letter? Its upper-case equivalent?)</entry>
</row>
<row>
<entry><envar>LC_MESSAGES</envar></entry>
<entry>Language of messages</entry>
</row>
<row>
<entry><envar>LC_MONETARY</envar></entry>
<entry>Formatting of currency amounts</entry>
</row>
<row>
<entry><envar>LC_NUMERIC</envar></entry>
<entry>Formatting of numbers</entry>
</row>
<row>
<entry><envar>LC_TIME</envar></entry>
<entry>Formatting of dates and times</entry>
</row>
</tbody>
</tgroup>
</informaltable>
The category names translate into names of
<command>initdb</command> options to override the locale choice
for a specific category. For instance, to set the locale to
French Canadian, but use U.S. rules for formatting currency, use
<literal>initdb --locale=fr_CA --lc-monetary=en_US</literal>.
</para>
<para>
If you want the system to behave as if it had no locale support,
use the special locale name <literal>C</literal>, or equivalently
<literal>POSIX</literal>.
</para>
<para>
Some locale categories must have their values
fixed when the database is created. You can use different settings
for different databases, but once a database is created, you cannot
change them for that database anymore. <literal>LC_COLLATE</literal>
and <literal>LC_CTYPE</literal> are these categories. They affect
the sort order of indexes, so they must be kept fixed, or indexes on
text columns would become corrupt.
(But you can alleviate this restriction using collations, as discussed
in <xref linkend="collation"/>.)
The default values for these
categories are determined when <command>initdb</command> is run, and
those values are used when new databases are created, unless
specified otherwise in the <command>CREATE DATABASE</command> command.
</para>
<para>
The other locale categories can be changed whenever desired
by setting the server configuration parameters
that have the same name as the locale categories (see <xref
linkend="runtime-config-client-format"/> for details). The values
that are chosen by <command>initdb</command> are actually only written
into the configuration file <filename>postgresql.conf</filename> to
serve as defaults when the server is started. If you remove these
assignments from <filename>postgresql.conf</filename> then the
server will inherit the settings from its execution environment.
</para>
<para>
Note that the locale behavior of the server is determined by the
environment variables seen by the server, not by the environment
of any client. Therefore, be careful to configure the correct locale settings
before starting the server. A consequence of this is that if
client and server are set up in different locales, messages might
appear in different languages depending on where they originated.
</para>
<note>