PostgreSQLã§æ¥æ¬èªã®ã½ã¼ããããããå ´åã®å¯¾å¦æ³
PostgreSQLã§æ¥æ¬èªãæ ¼ç´ããã¦ããã«ã©ã ãORDER BYã§ã½ã¼ãããããæããã«ããããé åºã§è¿ã£ã¦ããã
test=# select name from test_table order by name asc; name
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
ãããªæãã
ã¾ãlocaleã¨ãcollateã®åé¡ãªãã ãããªã¼ã¨æãã¤ã¤ãPostgreSQLã§ã¯ã©ããªã£ã¦ãã®ãç¥ããªãã£ãã®ã§ããããå çã«ã伺ããç«ã¦ã¦ã¿ãããã©ããããã¼ã¿ãã¼ã¹ã¯ã©ã¹ã¿ã®åæåæï¼initdbæï¼ã«æå®ãããã®ãä¸ç使ãããããããå¤æ´ä¸å¯ï¼ãã¼
追è¨ï¼8.4ããã¯createdbæã«æå®ã§ããã¿ããã
ç¾å¨ã®è¨å®ã®ç¢ºèª
pg_controldataã³ãã³ãã§ç¢ºèªã§ãããããã
$ pg_controldata /var/lib/pgsql/data
pg_control version number: 812 Catalog version number: 200510211 Database system identifier: 5197600922672676756 Database cluster state: in production pg_control last modified: Tue 09 Sep 2008 11:15:42 AM JST Current log file ID: 0 Next log file segment: 2 Latest checkpoint location: 0/1D56BEC Prior checkpoint location: 0/1D3E6FC Latest checkpoint's REDO location: 0/1D56BEC Latest checkpoint's UNDO location: 0/0 Latest checkpoint's TimeLineID: 1 Latest checkpoint's NextXID: 617956 Latest checkpoint's NextOID: 65776 Latest checkpoint's NextMultiXactId: 1 Latest checkpoint's NextMultiOffset: 0 Time of latest checkpoint: Tue 09 Sep 2008 11:15:42 AM JST Maximum data alignment: 4 Database block size: 8192 Blocks per segment of large relation: 131072 Bytes per WAL segment: 16777216 Maximum length of identifiers: 64 Maximum columns in an index: 32 Date/time type storage: floating-point numbers Maximum length of locale name: 128 LC_COLLATE: en_US.UTF-8 LC_CTYPE: en_US.UTF-8
æå¾ã®LC_COLLATEã¨LC_CTYPEã£ã¦ãã¤ããããã³ã°é¢ä¿ã®ãã±ã¼ã«ã§ããã®å ´åã¯en_US.UTF-8ã«ãªã£ã¦ããã
ã¡ãªã¿ã«ãã®ãµã¼ãã¯CentOS 5.1ã§PostgreSQLã¯ããã±ã¼ã¸ã§å
¥ãããã®ããã¼ã¿ãã¼ã¹ã¯EUC-JPã¨ããæ§æã
ãã®ãã±ã¼ã«ã¨ãã¼ã¿ãã¼ã¹ã®ã¨ã³ã³ã¼ãã£ã³ã°ã®ä¸ä¸è´ãåé¡ã®ããã ã
ãã±ã¼ã«ãæå®ãã¦åæåãã
ãã¼ã¿ãã¼ã¹ã®ã¨ã³ã³ã¼ãã£ã³ã°ãå¤ããããã«ã¯ãããªãã®ã§ãã±ã¼ã«ãå¤ãããããã ããLC_COLLATEã¨LC_CTYPEã®äºã¤ã ãã¯initdbæã«ããè¨å®ã§ããªãããããéä¸ã§å¤ããå ´åã¯ãã³ãåã£ã¦åæåãç´ãã¦ãªã¹ãã¢ãããããªã模æ§ã
å¤æ´ãã§ããªãçç±ã¯ã¤ã³ããã¯ã¹æ
å ±ãããããã¨ãããã¥ã¢ã«ã«æ¸ãã¦ãã£ãã
ãã±ã¼ã«ã¯initdbæã«æå®ããã
ja_JP.EUC-JPã«è¨å® $ initdb --locale=ja_JP.EUC-JP Cãã±ã¼ã«ã«è¨å®ï¼ãã±ã¼ã«ã«ä¾åããå¦çãããªãï¼ $ initdb --locale=C --locale=Cã¨åã $ initdb --no-locale ããã©ã«ãã¨ã³ã³ã¼ãã£ã³ã°ãæå®ãããªã $ initdb -E EUC-JP --no-locale
ç¹å¥ã«ä½ãããããããã§ããªããã°--no-localeãç¡é£ãã
ã¤ããã±ã¼ã«æå®ãããcreatedbæã®ã¨ã³ã³ã¼ãã£ã³ã°ãäºå®ä¸ç¸ããããããªã