Reputation: 77
I have recently started using PostgreSQL for creating/updating existing SQL databases. Being rather new in this I came across an issue of selecting correct encoding type while creating new database. UTF-8 (default) did not work for me as data to be included is of various languages (English, Chinese, Japanese, Russia etc) as well as includes symbolic characters.
Question: What is the right database encoding type to satisfy my needs.
Any help is highly appreciated.
Upvotes: 1
Views: 936
Reputation: 324265
There are four different encoding settings at play here:
The server side encoding for the database
The client_encoding
that the PostgreSQL client announces to the PostgreSQL server. The PostgreSQL server assumes that text coming from the client is in client_encoding
and converts it to the server encoding.
The operating system default encoding. This is the default client_encoding
set by psql
if you don't provide a different one. Other client drivers might have different defaults; eg PgJDBC always uses utf-8
.
The encoding of any files or text being sent via the client driver. This is usually the OS default encoding, but it might be a different one - for example, your OS might be set to use utf-8
by default, but you might be trying to COPY
some CSV content that was saved as latin-1
.
You almost always want the server encoding set to utf-8
. It's the rest that you need to change depending on what's appropriate for your situation. You would have to give more detail (exact error messages, file contents, etc) to be able to get help with the details.
Upvotes: 2