UnixServerAdmin

Server Administration & Management

How to change database encoding value for postgresql database

We can change database encoding values for postgresql database by using following steps but make sure that you have taken backup for current database.

1. Log in to server as root user and switch to postgres

# su postgres

2. To check all database run

# psql -l

3. To switch database for example we are using support_test

# psql -d support_test

4. Run command to check encoding

support_test=# encoding
UTF8

SET CLIENT_ENCODING TO ‘LATIN1′;
or
SET NAMES ‘LATIN1′;

5. Now check encoding

support_test=# SHOW client_encoding;
client_encoding

November 14, 2011 Posted by | PgSQL | , | Leave a comment