Re: Losing my latin on Ordering... - Mailing list pgsql-general

From Laurenz Albe
Subject Re: Losing my latin on Ordering...
Date
Msg-id 8b429ae28697738330e13504d056c0a9a178e32c.camel@cybertec.at
Whole thread Raw
In response to Re: Losing my latin on Ordering...  (Dominique Devienne <ddevienne@gmail.com>)
List pgsql-general
On Tue, 2023-02-14 at 13:06 +0100, Dominique Devienne wrote:
> > Sure, just make sure to use the definition of C that uses UTF-8 encoding
> > (I think it's typically called C.UTF-8).
>  
> OK, so for new DBs, sounds like we need to
>
> CREATE DATABASE ... WITH LOCALE 'C.UTF-8' ENCODING UTF8 
>
> Correct?

Collations are identifiers, so it has to be double quotes.
The name depends on the operating system; if that is Unix-like,
you can run "locale -a" to get all available locales.

On my system it would be

CREATE DATABASE x TEMPLATE template0 LOCALE "C.utf8" ENCODING UTF8;

> But what about existing DBs? Can the collation be changed a posteriori?
> ALTER DATABASE does not seem to support the same options.
>
> We don't want to have to sprinkle COLLATE "C" all over the place in the code.
> And there are quite a few DBs out there already. What to do about them?

The only option is dump/restore.

A changed collation means changed indexes, so there is no better option.

Yours,
Laurenz Albe



pgsql-general by date:

Previous
From: Dominique Devienne
Date:
Subject: Re: Losing my latin on Ordering...
Next
From: Sebastien Flaesch
Date:
Subject: Multi-column index: Which column order