How to change the template database collection coding

后端 未结 2 715
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 14:07

I want build new postgreSQL database by:

CREATE DATABASE newdb
WITH OWNER = postgres
   ENCODING = \'UTF8\'
   TABLESPACE = pg_default
   LC_COLLATE = \'zh_C         


        
2条回答
  •  执笔经年
    2020-12-13 14:35

    Tomas answer is correct, but it is missing an important detail (LC_CTYPE). Here is the full sequence for recreating template1 with the correct locale:

    ALTER database template1 is_template=false;
    
    DROP database template1;
    
    CREATE DATABASE template1
    WITH OWNER = postgres
       ENCODING = 'UTF8'
       TABLESPACE = pg_default
       LC_COLLATE = 'zh_CN.UTF-8'
       LC_CTYPE = 'zh_CN.UTF-8'
       CONNECTION LIMIT = -1
       TEMPLATE template0;
    
    ALTER database template1 is_template=true;
    

    then you can create new databases.

提交回复
热议问题