PostgreSQL Sort

后端 未结 4 666
执笔经年
执笔经年 2020-12-07 03:45

I have a sort problem in PostgreSQL with below data:

name
-----
@CF
@CG
CD
CE

I used select name from table order by name, the

4条回答
  •  余生分开走
    2020-12-07 04:32

    Use PostgreSQL's collation support to tell it you want a particular collation.

    Given:

    CREATE TABLE t AS VALUES ('CD'),('CE'),('@CF'),('@CE');
    

    You can force byte-wise collation using:

    SELECT * FROM t ORDER BY column1 COLLATE "C";
    

    The "C" collation is a byte-wise collation that ignores national language rules, encoding, etc.

提交回复
热议问题