Subject: Choosing default collation/ctype

From: Igor Korot <[email-masked]>
Date: Sun, 3 May 2026 14:52:18 -0500

Hi, ALL,
In the CREATE DATABASE statement I can use encoding/collation/ctype.

I can retrieve the encoding list with:

[code]
SELECT pg_encoding_to_char( conforencoding ) AS name FROM pg_conversion
[/code]

And then I can get a list of collations/ctypes with:

[code]
SELECT collname, collencoding, collprovider collctype FROM pg_collation
[/code]

And then add a logic in my UI to switch collations/ctypes based on encoding.

However, what I wonder is:

Is there a way to select a default collation/ctype for a specific encoding?

Or maybe I'm overthinking it and I should let the user choose and if
nothing - just keep those 2 as "Default" and let the server pick it
up. However it will be weird, especially from me as a user POV.

Please advise.

Thank you.

---

From: Peter Eisentraut <[email-masked]>
Date: Wed, 6 May 2026 08:05:15 +0200

> up. However it will be weird, especially from me as a user POV.

There is no default collation/ctype (locale) for an encoding, only the 
other way around.  So if a user picks as locale, let's say, de_DE@euro, 
then the encoding is automatically LATIN9 (obsolete), if the locale is 
de_DE.utf8, then the encoding is UTF8, and so on.