UTF8 Postgresql Create Database Like MySQL(包括字符集、编码和lc_type)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9961795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UTF8 Postgresql Create Database Like MySQL (including character set, encoding, and lc_type)
提问by Wil Moore III
For the following MySQL create database statement, what would be the equivalent in postgresql?:
对于以下 MySQL create database 语句,postgresql 中的等价物是什么?:
CREATE DATABASE IF NOT EXISTS `scratch`
DEFAULT CHARACTER SET = utf8
DEFAULT COLLATE = utf8_unicode_ci;
I currently have:
我目前有:
CREATE DATABASE "scratch"
WITH OWNER "postgres"
ENCODING 'UTF8'
TABLESPACE "pg_default";
Is that enough or should I be more specific including LOCALE
as well?
这足够了吗,或者我应该更具体地包括在内LOCALE
吗?
回答by michael.bochkaryov
Yes, you can be more specific.
是的,你可以更具体。
For example:
例如:
CREATE DATABASE "scratch"
WITH OWNER "postgres"
ENCODING 'UTF8'
LC_COLLATE = 'en_US.UTF-8'
LC_CTYPE = 'en_US.UTF-8';
Also I recommend to read the following pages about locales and collations in PostgreSQL:
此外,我建议阅读以下有关 PostgreSQL 中的语言环境和排序规则的页面: