PostgreSQL – Storing Unicode Characters is Easy

PostgreSQL varchar can store Unicode with suitable database and client encodings. My example stores ЯНВАРЬ, the Russian word for January.

A woven motif remains intact on a source cloth and a separately framed copy.

SHOW server_encoding;
SHOW client_encoding;
CREATE TEMP TABLE testing1 (col varchar(100));
INSERT INTO testing1 (col) VALUES ('ЯНВАРЬ');
SELECT col FROM testing1;
DROP TABLE testing1;
Original PostgreSQL result containing ЯНВАРЬ.
Original PostgreSQL result containing ЯНВАРЬ.

Use UTF8 and compatible client encoding for broadly multilingual data. A character type alone can’t make every encoding support every character. SQL_ASCII is not a substitute for correct Unicode handling.

SQL Server nvarchar and nchar remain straightforward Unicode choices. SQL Server 2019 also supports UTF-8 collations with varchar. My earlier comparison therefore needed qualification. Check client encoding, literals and collation in either product.

This PostgreSQL example uses a temporary table. It leaves no permanent testing object. The multilingual SQL Server article and PostgreSQL learning resources provide additional context.

Reference: PostgreSQL character-set support.

Related reading

A character type is not a complete encoding configuration, it is one part of preserving multilingual text.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

PostgreSQL, SQL Function, SQL String, Unicode
Previous Post
Tracking Backup Throughput and Duration From msdb History
Next Post
SQL SERVER – Windows Authentication or System Admin Account (SA)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.