Re: Change postgresql encoding - Mailing list pgsql-general

From Oliver
Subject Re: Change postgresql encoding
Date
Msg-id CALQkqm-SCKFqwJqYWkcQBtk_cSer-cnqDApWspJ00y5rg_zcmA@mail.gmail.com
Whole thread Raw
In response to Re: Change postgresql encoding  (BladeOfLight16 <bladeoflight16@gmail.com>)
Responses Re: Change postgresql encoding
List pgsql-general
2015-02-08 20:50 GMT+00:00 BladeOfLight16 <bladeoflight16@gmail.com>:
On Sun, Feb 8, 2015 at 2:20 PM, Oliver <ofabelo@gmail.com> wrote:
If I want change postgresql encoding, I have understood that I should reinstall postgresql (I do installation from rpm official binary files for red hat)

I can't answer your question about whether the encodings need to be the same, but I'm pretty sure that's not true. CREATE DATABASE has options to set the encoding for a database:

CREATE DATABASE korean WITH ENCODING 'EUC_KR' LC_COLLATE='ko_KR.euckr' LC_CTYPE='ko_KR.euckr' TEMPLATE=template0;

(From http://www.postgresql.org/docs/9.4/static/multibyte.html)

To change the encoding of an existing PG database, you have to 1) dump it, 2) create a new, empty DB with the desired encoding, and 3) import the dump into the new DB. So you can't really change it "on the fly," but it can be done at creation time.

How it would be if I want latin9 encoding? I'm trying the next but it shows that it is not valid (es_ES.latin9):

CREATE DATABASE xxx
  WITH ENCODING 'LATIN9'
       OWNER=xxx
       TEMPLATE=template0
       LC_COLLATE='es_ES.latin9'
       LC_CTYPE='es_ES.latin9'
       CONNECTION LIMIT=-1
       TABLESPACE=xxx;

Thanks beforehand.

pgsql-general by date:

Previous
From: Oliver
Date:
Subject: Re: Change postgresql encoding
Next
From: Oliver
Date:
Subject: Re: Change postgresql encoding