Pivotal Knowledge Base


How to Change the Encoding of the Database


Pivotal Greenplum Database (GPDB)


This article describes how to change the encoding of the database.


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 the encoding of an existing database

-- Dump the entire database with gpcrondump

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

-- Create a 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.


Powered by Zendesk