1- <!-- $PostgreSQL: pgsql/doc/src/sgml/charset.sgml,v 2.87 2008/07/15 17:45:03 momjian Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/charset.sgml,v 2.88 2008/09/23 09:20:34 heikki Exp $ -->
22
33<chapter id="charset">
44 <title>Localization</>
@@ -130,23 +130,23 @@ initdb --locale=sv_SE
130130
131131 <para>
132132 The nature of some locale categories is that their value has to be
133- fixedfor thelifetime of a database cluster. That is, once
134- <command>initdb</command> has run, you cannot change them anymore.
135- <literal>LC_COLLATE</literal> and <literal>LC_CTYPE </literal> are
136- those categories. They affect the sort order of indexes, so they
137- must be kept fixed, or indexes on text columns will become corrupt.
138- <productname>PostgreSQL</productname> enforces this by recording
139- the values of <envar>LC_COLLATE</> and <envar>LC_CTYPE</> that are
140- seen by <command>initdb</>. The server automatically adopts
141- those two values when it is started .
133+ fixedwhen thedatabase is created. You can use different settings
134+ for different databases, but once a database is created, you cannot
135+ change them for that database anymore. <literal>LC_COLLATE </literal>
136+ and <literal>LC_CTYPE</literal> are those categories. They affect
137+ the sort order of indexes, so they must be kept fixed, or indexes on
138+ text columns will become corrupt. The default values for these
139+ categories are defined when <command>initdb</command> is run, and
140+ those values are used when new databases are created, unless
141+ specified otherwise in the <command>CREATE DATABASE</command> command .
142142 </para>
143143
144144 <para>
145145 The other locale categories can be changed as desired whenever the
146146 server is running by setting the run-time configuration variables
147147 that have the same name as the locale categories (see <xref
148- linkend="runtime-config-client-format"> for details). The defaults that are
149- chosen by <command>initdb</command> are actually only written into
148+ linkend="runtime-config-client-format"> for details). The defaults
149+ that are chosen by <command>initdb</command> are actually only written into
150150 the configuration file <filename>postgresql.conf</filename> to
151151 serve as defaults when the server is started. If you delete these
152152 assignments from <filename>postgresql.conf</filename> then the
@@ -261,7 +261,7 @@ initdb --locale=sv_SE
261261
262262 <para>
263263 Check that <productname>PostgreSQL</> is actually using the locale
264- that you think it is. <envar>LC_COLLATE</> and <envar>LC_CTYPE</>
264+ that you think it is.The default <envar>LC_COLLATE</> and <envar>LC_CTYPE</>
265265 settings are determined at <command>initdb</> time and cannot be
266266 changed without repeating <command>initdb</>. Other locale
267267 settings including <envar>LC_MESSAGES</> and <envar>LC_MONETARY</>
@@ -319,17 +319,11 @@ initdb --locale=sv_SE
319319 </para>
320320
321321 <para>
322- An important restriction, however, is that each database character set
323- must be compatible with theserver 's <envar>LC_CTYPE</> setting.
322+ An important restriction, however, is that each database's character set
323+ must be compatible with thedatabase 's <envar>LC_CTYPE</> setting.
324324 When <envar>LC_CTYPE</> is <literal>C</> or <literal>POSIX</>, any
325325 character set is allowed, but for other settings of <envar>LC_CTYPE</>
326326 there is only one character set that will work correctly.
327- Since the <envar>LC_CTYPE</> setting is frozen by <command>initdb</>, the
328- apparent flexibility to use different encodings in different databases
329- of a cluster is more theoretical than real, except when you select
330- <literal>C</> or <literal>POSIX</> locale (thus disabling any real locale
331- awareness). It is likely that these mechanisms will be revisited in future
332- versions of <productname>PostgreSQL</productname>.
333327 </para>
334328
335329 <sect2 id="multibyte-charset-supported">
@@ -734,19 +728,19 @@ initdb -E EUC_JP
734728 </para>
735729
736730 <para>
737- If you have selected <literal>C</> or <literal>POSIX</> locale ,
738- you can create a database witha different character set :
731+ You can specify a non-default encoding at database creation time ,
732+ provided that the encoding is compatible withthe selected locale :
739733
740734<screen>
741- createdb -E EUC_KR korean
735+ createdb -E EUC_KR-T template0 --lc-collate=ko_KR.euckr --lc-ctype=ko_KR.euckr korean
742736</screen>
743737
744738 This will create a database named <literal>korean</literal> that
745- uses the character set <literal>EUC_KR</literal>. Another way to
746- accomplish this is to use this SQL command:
739+ uses the character set <literal>EUC_KR</literal>, and locale <literal>ko_KR</literal>.
740+ Another way to accomplish this is to use this SQL command:
747741
748742<programlisting>
749- CREATE DATABASE korean WITH ENCODING 'EUC_KR';
743+ CREATE DATABASE korean WITH ENCODING 'EUC_KR' COLLATE='ko_KR.euckr' CTYPE='ko_KR.euckr' TEMPLATE=template0 ;
750744</programlisting>
751745
752746 The encoding for a database is stored in the system catalog
@@ -756,20 +750,17 @@ CREATE DATABASE korean WITH ENCODING 'EUC_KR';
756750
757751<screen>
758752$ <userinput>psql -l</userinput>
759- List of databases
760- Database | Owner | Encoding
761- ---------------+---------+---------------
762- euc_cn | t-ishii | EUC_CN
763- euc_jp | t-ishii | EUC_JP
764- euc_kr | t-ishii | EUC_KR
765- euc_tw | t-ishii | EUC_TW
766- mule_internal | t-ishii | MULE_INTERNAL
767- postgres | t-ishii | EUC_JP
768- regression | t-ishii | SQL_ASCII
769- template1 | t-ishii | EUC_JP
770- test | t-ishii | EUC_JP
771- utf8 | t-ishii | UTF8
772- (9 rows)
753+ List of databases
754+ Name | Owner | Encoding | Collation | Ctype | Access Privileges
755+ -----------+----------+-----------+-------------+-------------+-------------------------------------
756+ clocaledb | hlinnaka | SQL_ASCII | C | C |
757+ englishdb | hlinnaka | UTF8 | en_GB.UTF8 | en_GB.UTF8 |
758+ japanese | hlinnaka | UTF8 | ja_JP.UTF8 | ja_JP.UTF8 |
759+ korean | hlinnaka | EUC_KR | ko_KR.euckr | ko_KR.euckr |
760+ postgres | hlinnaka | UTF8 | fi_FI.UTF8 | fi_FI.UTF8 |
761+ template0 | hlinnaka | UTF8 | fi_FI.UTF8 | fi_FI.UTF8 | {=c/hlinnaka,hlinnaka=CTc/hlinnaka}
762+ template1 | hlinnaka | UTF8 | fi_FI.UTF8 | fi_FI.UTF8 | {=c/hlinnaka,hlinnaka=CTc/hlinnaka}
763+ (7 rows)
773764</screen>
774765 </para>
775766