Let's say that the character set of the PostgreSQL server is UTF-8 and you connect to the server via a Windows client, which uses the SJIS encoding by default. In such a case, the client encoding will be used for the data unless you specify a different one.
If you want to use the encoding of the server when extracting data to a file, use the COPY command and specify the PostgreSQL server encoding in the ENCODING option.
In this example, the character encoding of the PostgreSQL server is UTF-8 and you want to extract the data from myschema.table1 to C:\tmp\table1.txt.
mydb=# \copy myschema.table1 to 'C:\tmp\table1.txt' encoding 'UTF8';Use the meta command (\copy) to access the client file. The encoding of the data output to C:\tmp\table1.txt will be UTF-8 as specified above.
mydb=# SHOW client_encoding;
client_encoding
-----------------
SJIS
(1 row)
Fujitsu Enterprise Postgres is designed for developers, data architects, and DBAs seeking the efficiency of a leading open source based database technology with the enhanced security and performance features plus support required in a serious business environment.
Read our most recent articles regarding all aspects of PostgreSQL and Fujitsu Enterprise Postgres.