■Postgesql初期化処理で--no-locale

■Postgesql初期化処理で--no-locale

postgresqlのパラメータlc_collate,lc_ctypeがCでないと、日本語ソートが正しくない動きをするらしい。検証はしていないが、お約束としてメモ。8.4系だと、CreateDB時に設定可能らしい。

↓postgresにsu
[root@localhost ~]# su - postgres

↓.bash_profileのPGDATAを確認

[ -f /etc/profile ] && source /etc/profile

PGDATA=/var/lib/pgsql/data
export PGDATA

↓データベース初期化

  • bash-3.00$ initdb --no-locale

↓確認方法

Welcome to psql 8.1.11, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

postgres=# SHOW ALL;
lc_collate | C
lc_ctype | C
lc_messages | C
lc_monetary | C
lc_numeric | C
lc_time | C

lc_collate とlc_ctype がCならばOK
ja.UTFとかだと、やり直し