* 文字コードを指定して作成する [#p4daf038]
CREATE DATABASE foo_db ENCODING 'UTF8'
CREATE DATABASE bar_db ENCODING 'SJIS'
** template1のエンコーディングと違うエンコーディングを指定するとエラーになる [#ya8279a3]
ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
上のようにエラーが起きる。この場合、以下のようにする。
CREATE DATABASE foo_db ENCODING 'UTF8' TEMPLATE template0
- TEMPLATEオプション付けて、template0を指定する
- template1はinitdbした時のエンコーディング
** 参考 [#jee01536]
- https://www.postgresql.org/docs/current/static/sql-createdatabase.html
- https://www.postgresql.org/docs/current/static/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED
- https://www.dbonline.jp/postgresql/database/index2.html