Changing collate & ctype for an existing database

From: rihad <rihad(at)mail(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: Changing collate & ctype for an existing database
Date: 2017-07-10 16:21:41
Message-ID: dc2272e2-1da2-003c-a018-58a06c278571@mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there. We have a working database that was unfortunately created by
initdb with default ("C") collation & ctype. All other locale specific
settings have the value en_US.UTF-8 in postgresql.conf. The database
itself is multilingual and all its data is stored in UTF-8. Sorting
doesn't work correctly, though. To fix that, can I just do this:

update pg_database set datcollate='en_US.UTF-8', datctype='en_US.UTF-8'
where datname='mydb';

This does seem to work on a testing copy of the database, i.e. select
lower('БлаБлаБла') now works correctly when connected to that database.

Is there still any chance for corrupting data by doing this, or indexes
stopping working etc?

p.s.: postgres 9.6.3

Thanks.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message rihad 2017-07-10 16:31:33 Changing collate & ctype for an existing database
Previous Message Alexander Farber 2017-07-10 14:32:14 How to handle simultaneous FOR-IN UPDATE-RETURNING loops?