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 $ -->
2
2
3
3
<chapter id="charset">
4
4
<title>Localization</>
@@ -130,23 +130,23 @@ initdb --locale=sv_SE
130
130
131
131
<para>
132
132
The nature of some locale categories is that their value has to be
133
- fixed for the lifetime 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
+ fixed when the database 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 .
142
142
</para>
143
143
144
144
<para>
145
145
The other locale categories can be changed as desired whenever the
146
146
server is running by setting the run-time configuration variables
147
147
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
150
150
the configuration file <filename>postgresql.conf</filename> to
151
151
serve as defaults when the server is started. If you delete these
152
152
assignments from <filename>postgresql.conf</filename> then the
@@ -261,7 +261,7 @@ initdb --locale=sv_SE
261
261
262
262
<para>
263
263
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</>
265
265
settings are determined at <command>initdb</> time and cannot be
266
266
changed without repeating <command>initdb</>. Other locale
267
267
settings including <envar>LC_MESSAGES</> and <envar>LC_MONETARY</>
@@ -319,17 +319,11 @@ initdb --locale=sv_SE
319
319
</para>
320
320
321
321
<para>
322
- An important restriction, however, is that each database character set
323
- must be compatible with the server 's <envar>LC_CTYPE</> setting.
322
+ An important restriction, however, is that each database's character set
323
+ must be compatible with the database 's <envar>LC_CTYPE</> setting.
324
324
When <envar>LC_CTYPE</> is <literal>C</> or <literal>POSIX</>, any
325
325
character set is allowed, but for other settings of <envar>LC_CTYPE</>
326
326
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>.
333
327
</para>
334
328
335
329
<sect2 id="multibyte-charset-supported">
@@ -734,19 +728,19 @@ initdb -E EUC_JP
734
728
</para>
735
729
736
730
<para>
737
- If you have selected <literal>C</> or <literal>POSIX</> locale ,
738
- you can create a database with a different character set :
731
+ You can specify a non-default encoding at database creation time ,
732
+ provided that the encoding is compatible with the selected locale :
739
733
740
734
<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
742
736
</screen>
743
737
744
738
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:
747
741
748
742
<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 ;
750
744
</programlisting>
751
745
752
746
The encoding for a database is stored in the system catalog
@@ -756,20 +750,17 @@ CREATE DATABASE korean WITH ENCODING 'EUC_KR';
756
750
757
751
<screen>
758
752
$ <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)
773
764
</screen>
774
765
</para>
775
766
0 commit comments