zoukankan      html  css  js  c++  java
  • PostgreSQL中的collations

    与Oracle相比,PostgreSQL对collation的支持依赖于操作系统。

     

    以下是基于Centos7.5的测试结果

    $ env | grep LC
    $ env | grep LANG
    LANG=en_US.UTF-8
    

      

    使用initdb初始化集群的时候,就会使用这些操作系统的配置。

    postgres=# l
                                      List of databases
       Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
    -----------+----------+----------+-------------+-------------+-----------------------
     postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
     template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
    (4 rows)
    
    postgres=# 
    

      

    在新建数据库的时候,可以指定数据库的默认的callation:

    postgres=# create database abce with LC_COLLATE = "en_US.UTF-8";
    CREATE DATABASE
    postgres=# create database abce2 with LC_COLLATE = "de_DE.UTF-8";
    ERROR:  new collation (de_DE.UTF-8) is incompatible with the collation of the template database (en_US.UTF-8)
    HINT:  Use the same collation as in the template database, or use template0 as template.
    postgres=# 
    

    但是,指定的collation必须是与template库兼容的。或者,使用template0作为模板。

     

    如果想看看操作系统支持哪些collations,可以执行:

    $ localectl list-locales
    

      

    也可以登录postgres后查看:

    postgres=# select * from pg_collation ;
    

      

  • 相关阅读:
    复利计算单元测试-软件工程
    实验一 操作系统
    <构建之法>前三章读后感—软件工程
    复利计算总结-软件工程
    实验0-操作系统
    复利计算1.0~2.0~3.0~4.0-软件工程(网页版)
    典型用户与场景
    0608场景(用户故事) 任务
    构建之法读后感+学习和诚信
    0603团队变化+sprint第二个冲刺
  • 原文地址:https://www.cnblogs.com/abclife/p/13924350.html
Copyright © 2011-2022 走看看