如何更改Postgresql上的模板数据库集合编码
我想通过以下方式构建新的postgreSQL数据库:
CREATE DATABASE newdb WITH OWNER = postgres ENCODING = 'UTF8' TABLESPACE = pg_default LC_COLLATE = 'zh_CN.UTF-8' CONNECTION LIMIT = -1; 错误是: 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. 如何更改模板数据库集合?使它成为(zh_CN.UTF-8)
从
PostgreSQL文档:
您只能使用template0创建具有不同编码和区域设置的新数据库: CREATE DATABASE newdb WITH OWNER = postgres ENCODING = 'UTF8' TABLESPACE = pg_default LC_COLLATE = 'zh_CN.UTF-8' CONNECTION LIMIT = -1 TEMPLATE template0; 这将工作,但这意味着您对template1所做的任何更改将不会应用于新创建的数据库。 要更改template1的编码和排序规则,您必须先删除template1,然后从template0创建新的模板template1。如何删除模板数据库描述here.然后,您可以通过设置datistemplate = true(example)来创建具有所选编码/排序规则的新数据库template1并将其标记为模板: update pg_database set datistemplate=true where datname='template1'; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |