Re: Change server encoding after the fact

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Cody Caughlan <toolbag(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Change server encoding after the fact
Date: 2011-09-30 18:05:51
Message-ID: CAOR=d=1DVVJs3iBj8sjMCEgx6mPjdgQ2hSPNBeV4sGKGnujQPw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Sep 30, 2011 at 11:25 AM, Cody Caughlan <toolbag(at)gmail(dot)com> wrote:
> I would like to change my server_encoding which is currently SQL_ASCII to UTF8.
>
> I have existing data that I would like to keep.
>
> From my understanding of the steps I need to:
>
> 1) alter the template1 database encoding via
>
> UPDATE pg_database SET encoding = 6 where datname IN ('template0', 'template1');

Just create database using template0 as template and you can skip this step ^^
> Are these the correct steps to perform or is there an easier / in-place way?

> Also, when I dump my old DB and restore it, will it be converted appropriately (e.g. it came from am SQL_ASCII encoding and its going into a UTF-8 database)?

You might need to set client encoding when restoring. Or use iconv to
convert from one encoding to another, which is what I usually do.
Note that it's VERY likely you'll have data in a SQL_ASCII db that
won't go into a UTF8 database without some lossiness.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Cody Caughlan 2011-09-30 18:26:36 Re: Change server encoding after the fact
Previous Message Henry Drexler 2011-09-30 17:41:33 Re: postgres for OLAP & data mining