UTF8 Postgresql创建数据库,如MySQL(包括字符集、编码和lc_type)

时间:2022-08-27 01:11:38

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中的地区和排序的页面:

#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中的地区和排序的页面: