inline PostgreSQL UTF-8 Database

Originally published on May 11th, 2020 (Last updated on May 11th, 2020)

Cre­at­ing a UTF8 encod­ed Data­base requires at a min­i­mum the encod­ing. Locale and col­late can be spec­i­fied as well, which will influ­ence case-insen­si­tive search­ing and sort­ing behavior:

# Minimum 
CREATE DATABASE "<db>" WITH OWNER '<user>' ENCODING 'UTF8';
# Explicit
CREATE DATABASE "<db>" WITH OWNER '<user>' ENCODING 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';

Note: The psql util­i­ty will accept the above state­ment with­out a ter­mi­nat­ing ; but it will nev­er exe­cute it! Don’t for­get the ter­mi­nat­ing semicolon!

Tak­en from this Stack­Over­flow Answer

Comments

No com­ment sec­tion here 😄

You can reach me over at @knuth_dev or send me an Email.