PostgreSQL order by convert_to(info,‘GB18030‘)汉字按拼音排序 📅 2026/8/26 19:40:32 建库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 | | | | | postgresCTc/postgres template1 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | c/postgres | | | | | postgresCTc/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#