Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Change The Template Database Collection Coding On Postgresql

CREATE DATABASE newdb
WITH OWNER = postgres
   ENCODING = 'UTF8'
   TABLESPACE = pg_default
   LC_COLLATE = 'zh_CN.UTF-8'
   CONNECTION LIMIT = -1;
and the error is:
ERROR:  new collation (zh_CN.UTF-8) is incompatible with the collation of the template    database (en_US.UTF8)
HINT:  Use the same collation as in the template database, or use template0 as template.

Solution:
Another common reason for copying template0 instead of template1 is that new encoding and locale settings can be specified when copying template0, whereas a copy of template1 must use the same settings it does. This is because template1 might contain encoding-specific or locale-specific data, while template0 is known not to.
You can use only template0 to create new database with different encoding and locale:
CREATE DATABASE newdb
WITH OWNER = postgres
   ENCODING = 'UTF8'
   TABLESPACE = pg_default
   LC_COLLATE = 'zh_CN.UTF-8'
   CONNECTION LIMIT = -1
   TEMPLATE template0;
--Above command will work, however it means that any changes you made to template1 won't be applied to newly created database.
           (or)
To change encoding and collation of template1 you have to first delete template1 and then create new template template1 from template0. How to drop template database is described already. Then you can create new database template1 with chosen encoding/collation and mark it as a template by setting datistemplate=true (example):
update pg_database set datistemplate=true  where datname='template1';update pg_database set datistemplate=true  where datname='template1';

Comments

Popular posts from this blog

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?

7 Steps to configure BDR replication in postgresql

How to Get Table Size, Database Size, Indexes Size, schema Size, Tablespace Size, column Size in PostgreSQL Database

PostgreSQL Introduction

ERROR: operator does not exist: text ->> unknown LINE 1: ...stomer' as customer_name,sales_info ->>'PRODUCTS' ->>'produc... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.