将数据库的collate设置为en_US,数据会将默认使用这个collate按拼音排序。命令如下: createdatabase test03 encoding'UTF8'lc_collate'en_US.utf8'lc_ctype'en_US.utf8'template template0; \c test03select*from(values('Alice'),('Tom'))asa(c1)order
CREATE DATABASE database_c WITH ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' TEMPLATE=template0; 以上我们创建的数据库database_c 使用的字符集是 UTF8 ,同时使用的 COLLATE 和 CTYPE 为 C ,而如果你在创建数据库时不指定collate, ctype则你的数据库默认的collate, ctype 就为你初始化数据库时给出...
encoding 编码, lc_collate Collate属性, lc_ctype Ctype属性,这三个字段必须对应,设置时应同时设置。 allow_connection 允许连接,istemplate 是模板库 如:创建一个模板库 create database mytemplate encoding='UTF8' lc_ctype='en_US.UTF8' lc_collate='en_US.UTF8' IS_TEMPLATE true TEMPLATE template0; ...
lc_collate:在新数据库中使⽤的排序规则(LC_COLLATE)。这会影响应⽤于字符串的排序顺序,例如在使⽤ORDER BY的查询中,以及在⽂本列的索引中使⽤的顺序。 默认设置是使⽤模板数据库的排序规则。有关其他限制,请参⻅“注释”部分。 lc_ctype:在新数据库中使⽤的字符分类(LC_CTYPE)。 这会影响字符...
CREATEDATABASEdatabase_name[[WITH][OWNER[=]user_name][TEMPLATE[=]template][ENCODING[=]encoding][LC_COLLATE[=]lc_collate][LC_CTYPE[=]lc_ctype][TABLESPACE[=]tablespace_name][CONNECTIONLIMIT[=]connlimit]]; 1. 2. 3. 4. 5. 6. 7. ...
postgres=#createdatabaseabce2withLC_COLLATE ="de_DE.UTF-8"; ERROR: new collation (de_DE.UTF-8)isincompatiblewiththe collationofthe templatedatabase(en_US.UTF-8) HINT: Use the same collationasinthe templatedatabase,oruse template0astemplate. ...
不过从pg12开始支持不区分大小写,或者区分大小写的排序的collate。 CREATE COLLATION [ IF NOT EXISTS ] name ( [ LOCALE = locale, ] [ LC_COLLATE = lc_collate, ] [ LC_CTYPE = lc_ctype, ] [ PROVIDER = provider, ] [ DETERMINISTIC = boolean, ] ...
postgres=#showlc_collate;lc_collate---en_US.UTF-8(1row)postgres=#explain(costsoff)select*fromtwhereblike'A%';QUERYPLAN---SeqScanontFilter:(b~~'A%'::text)(2rows) 我们可以在创建索引时指定text_pattern_ops运算符类来克服这个限制(注意计划中的条件是如何变化的): postgres=#createindexont(btex...
lc_collate | {NOT_IN_SAMPLE} lc_ctype | {NOT_IN_SAMPLE} max_function_args | {NOT_IN_SAMPLE} max_identifier_length | {NOT_IN_SAMPLE} max_index_keys | {NOT_IN_SAMPLE} post_auth_delay | {NOT_IN_SAMPLE} pre_auth_delay | {NOT_IN_SAMPLE} ...
postgres=#createdatabasetmpdb_zh_cnwithtemplatetemplate0 lc_collate'zh_CN.UTF8'lc_ctype'zh_CN.UTF8'is_template=true; 在模板库中创建一些你需要预定义的东西,包括数据等等。 tmpdb_zh_cn=#createextensionhstore;CREATEEXTENSION 基于模板库创建数据库。