How to set SET CLIENT_ENCODING = UTF8 permanently?

2

I'm using PostgreSQL in my DATABASE Accented information is being recorded with accent problems.

Ex:

The record as Ã

Shark records as Shark

The encoding of my DATABASE and my server are using UTF8 as ENCODING . However, PostgreSQL has an environment variable called CLIENT_ENCODING that is responsible for controlling the encoding used by the client that is connected to the database server.

When I issue the SHOW

SHOW CLIENT_ENCODING;

It appears that my ENCODING is UNICODE

So every time I have to use the SET command, in each query tool window, to change its value and correct the accents. For example:

SET CLIENT_ENCODING = 'LATIN1';

NOTE: If I put 'UTF8' , it does not recognize special characters. I do not know why, since my bank is in 'UTF8' . It should recognize and display the accents, when I put in set UTF8 .

MY QUESTION IS:

Please, how can I let my client encoding according to the bank (UTF8 ), so that these errors do not happen with the accent?

    
asked by anonymous 09.08.2018 / 16:59

2 answers

1

You can add the command SET client_encoding = 'UTF8'; to the file ~/.psqlrc (or %APPDATA%\postgresql\psqlrc.conf in Windows)

For more details, see the manual : link

Reply like in English:

link

    
09.08.2018 / 19:43
0

You can set environment variables directly in the ROLE responsible for the session / connection, for example:

ALTER ROLE foobar SET CLIENT_ENCODING = 'UTF8';
    
10.08.2018 / 19:07