PostgreSQL 에서 한 자 를 병 음 으로 정렬 합 니 다.

9306 단어 PostgreSQL
참고 학습:
http://blog.163.com/digoal@126/blog/static/163877040201173003547236/
창 고 를 만들다
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=# 

좋은 웹페이지 즐겨찾기