119
<term><replaceable class="parameter">collate</replaceable></term>
119
<term><replaceable class="parameter">lc_collate</replaceable></term>
122
122
Collation order (<literal>LC_COLLATE</>) to use in the new database.
123
This affects the sort order applied to strings, e.g in queries with
123
This affects the sort order applied to strings, e.g. in queries with
124
124
ORDER BY, as well as the order used in indexes on text columns.
125
125
The default is to use the collation order of the template database.
126
126
See below for additional restrictions.
209
209
The character set encoding specified for the new database must be
210
compatible with the chosen LC_COLLATE and LC_CTYPE settings.
211
If <envar>LC_CTYPE</> is <literal>C</> (or equivalently
210
compatible with the chosen locale settings (<literal>LC_COLLATE</> and
211
<literal>LC_CTYPE</>). If the locale is <literal>C</> (or equivalently
212
212
<literal>POSIX</>), then all encodings are allowed, but for other
213
213
locale settings there is only one encoding that will work properly.
214
(On Windows, however, UTF-8 encoding can be used with any locale.)
214
215
<command>CREATE DATABASE</> will allow superusers to specify
215
<literal>SQL_ASCII</> encoding regardless of the locale setting,
216
<literal>SQL_ASCII</> encoding regardless of the locale settings,
216
217
but this choice is deprecated and may result in misbehavior of
217
218
character-string functions if data that is not encoding-compatible
218
219
with the locale is stored in the database.
222
The <literal>LC_COLLATE</> and <literal>LC_CTYPE</> settings must match
223
those of the template database, except when template0 is used as
224
template. This is because <literal>LC_COLLATE</> and <literal>LC_CTYPE</>
225
affects the ordering in indexes, so that any indexes copied from the
226
template database would be invalid in the new database with different
227
settings. <literal>template0</literal>, however, is known to not
228
contain any indexes that would be affected.
223
The encoding and locale settings must match those of the template database,
224
except when <literal>template0</> is used as template. This is because
225
other databases might contain data that does not match the specified
226
encoding, or might contain indexes whose sort ordering is affected by
227
<literal>LC_COLLATE</> and <literal>LC_CTYPE</>. Copying such data would
228
result in a database that is corrupt according to the new settings.
229
<literal>template0</literal>, however, is known to not contain any data or
230
indexes that would be affected.
260
To create a database <literal>music</> which supports the ISO-8859-1
262
To create a database <literal>music</> which supports the ISO-8859-1
264
CREATE DATABASE music ENCODING 'LATIN1';
266
CREATE DATABASE music ENCODING 'LATIN1' TEMPLATE template0;
265
267
</programlisting>
269
In this example, the <literal>TEMPLATE template0</> clause would only
270
be required if <literal>template1</>'s encoding is not ISO-8859-1.
271
Note that changing encoding might require selecting new
272
<literal>LC_COLLATE</> and <literal>LC_CTYPE</> settings as well.