转自:https://www.cnblogs.com/gaojian/p/3188609.html

postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
db_utf8 | gao | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 |
postgres | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 |
template0 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows) postgres=#
postgres=# \d
List of relations
Schema | Name | Type | Owner
--------+-------------------+-------+----------
public | gao_chinese_order | table | postgres
public | tbl_chinese_order | table | postgres
(2 rows) postgres=#
insert into tbl_chinese_order values ('刘少奇');

insert into tbl_chinese_order values ('刘德华');

insert into tbl_chinese_order values ('张学友');

普通排序

postgres=# select * from tbl_chinese_order order by info;
info
--------
刘少奇
刘德华
张学友
(3 rows)
postgres=# select * from tbl_chinese_order order by convert_to(info,'SQL_ASCII');
info
--------
刘少奇
刘德华
张学友
(3 rows) postgres=#

按拼音排序

postgres=# select * from tbl_chinese_order order by convert_to(info,'GBK');
info
--------
刘德华
刘少奇
张学友
(3 rows) postgres=#
postgres=# select * from tbl_chinese_order order by convert_to(info,'GB18030');
info
--------
刘德华
刘少奇
张学友
(3 rows) postgres=#

PostgreSQL对汉字按拼音排序的更多相关文章

  1. MySQL按照汉字的拼音排序

    按照汉字的拼音排序,用的比较多是在人名的排序中,按照姓氏的拼音字母,从A到Z排序: 如果存储姓名的字段采用的是GBK字符集,那就好办了,因为GBK内码编码时本身就采用了拼音排序的方法(常用一级汉字37 ...

  2. MySQL按照汉字的拼音排序,mysql汉字排序

    按照汉字的拼音排序,用的比较多是在人名的排序中,按照姓氏的拼音字母,从A到Z排序: 如果存储姓名的字段采用的是GBK字符集,那就好办了,因为GBK内码编码时本身就采用了拼音排序的方法(常用一级汉字37 ...

  3. MySQL按照汉字的拼音排序(转)

    按照汉字的拼音排序,用的比较多是在人名的排序中,按照姓氏的拼音字母,从A到Z排序: 如果存储姓名的字段采用的是GBK字符集,那就好办了,因为GBK内码编码时本身就采用了拼音排序的方法(常用一级汉字37 ...

  4. [转]Java汉字按照拼音排序

    最近项目上使用到汉字排序的问题,网上搜索了一下后普遍使用下面的方法比较. @Test public void test_sort_pinyin() { Collator cmp = Collator. ...

  5. MySQL按照汉字的拼音排序、按照首字母分类

    项目中有时候需要按照汉字的拼音排序,比如联系人列表.矿物分类等,有的还需要按拼音字母从A到Z分类显示. 如果存储汉字的字段编码使用的是GBK字符集,因为GBK内码编码时本身就采用了拼音排序的方法(常用 ...

  6. TP5 按照汉字的拼音排序

    业务需求:接口返回一个列表,但是这个列表要求按一定的条件排序,条件如下: 1,某字段(field1)为null的排前面 2,某字段(field2)为null的排前面 3,姓名(field3)按照汉字的 ...

  7. PostgreSQL下,对汉字按拼音排序

    参考学习此文: http://blog.163.com/digoal@126/blog/static/163877040201173003547236/ 建库 postgres=# \l List o ...

  8. js中文汉字按拼音排序

    JavaScript 提供本地化文字排序,比如对中文按照拼音排序,不需要程序显示比较字符串拼音. String.prototype.localeCompare 在不考虑多音字的前提下,基本可以完美实现 ...

  9. js 中实现 汉字按拼音排序

    let arr = ["贵州省", "江苏省", "江西省", "浙江省", "四川省", &quo ...

随机推荐

  1. 基于Python玩转人工智能最火框架 TensorFlow应用实践

    慕K网-299元-基于Python玩转人工智能最火框架 TensorFlow应用实践 需要联系我,QQ:1844912514

  2. 一次单体测试的采坑--MatcherAssert.assertThat---org.hamcrest 和org.mockito

    单体测试测试环境ci上报这个错, 本地没问题. org.hamcrest.Matcher.describeMismatch(Ljava/lang/Object;Lorg/hamcrest/Descri ...

  3. Jetson TX1刷机

    刷机流程 https://blog.csdn.net/c406495762/article/details/70786700 注意:教程中包含两步,首先安装Ubuntu系统,然后重启安装程序,安装其他 ...

  4. Analysis Services features supported by SQL Server editions

    Analysis Services (servers) Feature Enterprise Standard Web Express with Advanced Services Express w ...

  5. Debian社区群龙无首

    导读 前两天有过消息 Debian 包维护者 Michael Stapelberg 因对 Debian 社区的现状不满而宣布退出 Debian 的维护,该消息引发了人们对于 Debian 的担忧.11 ...

  6. Comet OJ Contest #2

    A:暴力,显然每两次至少翻一倍. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf ...

  7. 【XSY2851】蛋糕 数学

    题目大意 有一个边长为 \(1\) 的正 \(n\) 边形,你要把这个正 \(n\) 边形放到一个正 \(m\) 边形里面,且两个多边形的中心重合. 问你这个正 \(m\) 边形的边长最小是多少. \ ...

  8. bzoj 2049: [Sdoi2008]Cave 洞穴勘测 (LCT)

    链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2049 题面: 2049: [Sdoi2008]Cave 洞穴勘测 Time Limit: 1 ...

  9. 单元测试报错NoSuchBeanDefinitionException

    问题 在SpringBoot项目开发时,使用单元测试来运行一个Service,发现调用的一个Bean就是找不到,报错为: org.springframework.beans.factory.NoSuc ...

  10. Linux-Jenkins安装部署

    Jenkins 安装及插件安装 Jenkins简介: Jenkins只是一个平台,真正运作的都是插件.这就是jenkins流行的原因,因为jenkins什么插件都有 Hudson是Jenkins的前身 ...