Posts

Showing posts with the label Encoding

How to change PostgreSQL database encoding to UTF8

  The default encoding of the template databases in PostgreSQL is set to SQL_ASCII. If this encoding has not been changed, then the new databases will be created using this template and hence will have the same encoding SQL_ASCII. Overall this should not be a big problem unless Unicode data is required to be saved in the database. In that case you will receive an error such as : Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8. In this blog, we will go through all steps in order to change the encoding of the database to UTF8. First of all one needs to know that encoding of already created database cannot be altered. Hence we need to drop and create a new one. Checking the current server encoding. postgres@yourserver : ~ $ psql psql ( 10.7 ( Ubuntu 10.7 - 0ubuntu0 .18 . 04.1 ) ) Type "help" for help . postgres = # SHOW SERVER_ENCODING; server_encoding - - - - - - - - - - - - - - - - - SQL_ASCII ( 1 row ) po