エンコードディングとロケールの指定

initdb時かcreatedb時に指定。

$ createdb db_name --encoding=UTF8 --locale=ja_JP.UTF-8

こんなエラーが出ると、

createdb: database creation failed: ERROR:  new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT:  Use the same encoding as in the template database, or use template0 as template.

テンプレートを指定してあげるとOK。

$ createdb db_name --encoding=UTF8 --locale=ja_JP.UTF-8 -T template0

ロケールの活用はLet's postgresさんのロケール(国際化と地域化)の記事が勉強になる