Pivotal Knowledge Base

Follow

HowTo - Change the encoding of the database

Problem

How can i change the encoding of the database ?

Solution

The encoding of the existing database cannot be changed, so you will have to recreate the database to change the encoding.

Follow these steps to change encoding of an existing database

-- Dump the entire database with gpcrondump

gpcrondump -x <current_database_name> -E <current_encoding>;

-- Create new database with target Encoding,

create database test_utf8 encoding='<targt_encodning>';

-- Modify the file "gp_cdatabase_1_1_" of the dumps on MASTER. Change the create statement to the new database you have just created

create database test_utf8 WITH TEMPLATE = template0 ENCODING = 'UTF8' OWNER = gpadmin;

-- Load the data to the new database with target encoding:

gpdbrestore -s test_utf8 -t <dump_time_stamp>;

-- Change the database names

alter database <current_database_name> rename to <current_database_name_bak>;
alter database test_utf8 rename to <current_database_name>;

Verify the new database and drop the old one.

Comments

Powered by Zendesk