Setting "ucs_basic" as the default database collation
Is there a way to specify "ucs_basic" (or the other "standard collations" [1]https://www.postgresql.org/docs/current/collation.html#COLLATION-MANAGING-STANDARD) collation as the default database collation at database creation time, rather than on a per-column or per-operation basis?
[1]: https://www.postgresql.org/docs/current/collation.html#COLLATION-MANAGING-STANDARD
On Sun, Oct 27, 2024 at 5:32 AM Christophe Pettus <xof@thebuild.com> wrote:
Is there a way to specify "ucs_basic" (or the other "standard collations"
[1]) collation as the default database collation at database creation time,
rather than on a per-column or per-operation basis?[1]
https://www.postgresql.org/docs/current/collation.html#COLLATION-MANAGING-STANDARD
https://www.postgresql.org/docs/16/sql-createdatabase.html
The CREATE DATABASE statement has an ENCODING option. Does that work with
'ucs_basic'?
--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> crustacean!
On Oct 27, 2024, at 13:56, Ron Johnson <ronljohnsonjr@gmail.com> wrote:
The CREATE DATABASE statement has an ENCODING option. Does that work with 'ucs_basic'?
No:
xof=# create database test encoding=ucs_basic;
ERROR: ucs_basic is not a valid encoding name
LINE 1: create database test encoding=ucs_basic;
^
Although that's not too surprising; it's a UTF-8 collation, not an encoding as such. Experimenting with the various other CREATE DATABASE parameters hasn't gotten me any farther.
Christophe Pettus <xof@thebuild.com> writes:
Is there a way to specify "ucs_basic" (or the other "standard collations" [1]) collation as the default database collation at database creation time, rather than on a per-column or per-operation basis?
CREATE DATABASE wants you to specify a locale, which ucs_basic is not.
It's defined by SQL as a standard collation name, but that doesn't
make it a complete locale specification. You can do something like
regression=# create database db1 with encoding = 'utf8' locale = 'en_US.utf8' template = template0;
CREATE DATABASE
or
regression=# create database db2 with encoding = 'utf8' icu_locale = 'en-US-x-icu' locale_provider = icu template = template0;
CREATE DATABASE
or
regression=# create database db3 with encoding = 'utf8' locale = 'POSIX' template = template0;
CREATE DATABASE
regards, tom lane