Server Encoding and Client Encoding
Learn what is available for encoding in PostgreSQL.
We'll cover the following...
Encoding
An encoding is a particular representation of characters in bits and bytes. In the ASCII encoding, the letter A is encoded as the 7-bits byte 1000001, 65 in decimal, or 41 in hexadecimal. All those numbers are going to be written the same way on disk, and the letter A too.
Database encoding
The SQL_ASCII
encoding is a trap we need to avoid falling into. To know which encoding our database is using, run the psql command \l
. Type the following command after logging in to the database to see the output.
\l
The encoding here is UTF-8, which is the best choice these days, and we can see that the collation and ctype are English based in the UTF-8 encoding, which is good for our installation. We can, of course, pick ...