For the following MySQL create database statement, what would be the equivalent in postgresql?:
对于下面的MySQL创建数据库语句,在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 ?
1 个解决方案
#1
38
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中的地区和排序的页面:
- http://www.postgresql.org/docs/current/interactive/locale.html
- http://www.postgresql.org/docs/current/interactive/locale.html
- http://www.postgresql.org/docs/current/interactive/collation.html
- http://www.postgresql.org/docs/current/interactive/collation.html
#1
38
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中的地区和排序的页面:
- http://www.postgresql.org/docs/current/interactive/locale.html
- http://www.postgresql.org/docs/current/interactive/locale.html
- http://www.postgresql.org/docs/current/interactive/collation.html
- http://www.postgresql.org/docs/current/interactive/collation.html