Re: Change postgresql encoding

From: Nicolas Paris <niparisco(at)gmail(dot)com>
To:
Cc: Forums postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Change postgresql encoding
Date: 2015-02-09 12:45:38
Message-ID: CA+ssMOQ6eC8w_Kq9cRJO1=8iqkAQqj9H5w=d5470mxQakc3n7A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

Hello,

TRY in psql :

update pg_database set encoding = pg_char_to_encoding('your_encoding')
where datname = 'your_data_base';

Works for postgres 9.3

Nicolas PARIS

2015-02-09 9:11 GMT+01:00 Oliver <ofabelo(at)gmail(dot)com>:

> 2015-02-09 7:54 GMT+00:00 Oliver <ofabelo(at)gmail(dot)com>:
>
>> 2015-02-08 20:50 GMT+00:00 BladeOfLight16 <bladeoflight16(at)gmail(dot)com>:
>>
>>> On Sun, Feb 8, 2015 at 2:20 PM, Oliver <ofabelo(at)gmail(dot)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.
>>
>>
> If I set encoding to latin9, lc_collate and lc_ctype to 'C', database is
> created correctly, but I'm not sure if it is ok :-? I want have database
> with iso8859-15 encoding.
> My system has, when I run 'locale', the next:
>
> LANG=es_ES.UTF-8
> LC_CTYPE="es_ES.UTF-8"
> LC_NUMERIC="es_ES.UTF-8"
> LC_TIME="es_ES.UTF-8"
> LC_COLLATE="es_ES.UTF-8"
> LC_MONETARY="es_ES.UTF-8"
> LC_MESSAGES="es_ES.UTF-8"
> LC_PAPER="es_ES.UTF-8"
> LC_NAME="es_ES.UTF-8"
> LC_ADDRESS="es_ES.UTF-8"
> LC_TELEPHONE="es_ES.UTF-8"
> LC_MEASUREMENT="es_ES.UTF-8"
> LC_IDENTIFICATION="es_ES.UTF-8"
> LC_ALL=
>
> Thanks beforehand.
>
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Geoff Winkless 2015-02-09 12:48:51 Re: [ADMIN] <empty string> Vs NULL
Previous Message Marc Mamin 2015-02-09 12:42:29 Re: [PERFORM] <empty string> Vs NULL

Browse pgsql-general by date

  From Date Subject
Next Message Vincent Veyron 2015-02-09 14:01:07 Re: Change postgresql encoding
Previous Message Marc Mamin 2015-02-09 10:14:11 Re: Partioning with overlapping and non overlapping constraints