Home > Database > Mysql Tutorial > body text

ORACLE按照拼音,部首,笔画排序

WBOY
Release: 2016-06-07 15:18:41
Original
1153 people have browsed it

下面的方法需要ORACLE9i和以上的版本才支持。 Oracle9i之前,中文是按照二进制编码进行排序的。 在oracle9i中新增了按照拼音、部首、笔画排序功能。设置NLS_SORT值 SCHINESE_RADICAL_M 按照部首(第一顺序)、笔划(第二顺序)排序 SCHINESE_STROKE_M 按照笔

 下面的方法需要ORACLE9i和以上的版本才支持。
Oracle9i之前,中文是按照二进制编码进行排序的。
在oracle9i中新增了按照拼音、部首、笔画排序功能。设置NLS_SORT值
SCHINESE_RADICAL_M 按照部首(第一顺序)、笔划(第二顺序)排序
SCHINESE_STROKE_M 按照笔划(第一顺序)、部首(第二顺序)排序
SCHINESE_PINYIN_M 按照拼音排序,系统的默认排序方式为拼音排序

举例如下:
表名为 dept ,其中name字段是中文,下面分别实现按照单位名称的笔划、部首和拼音排序。

<span><font face="新宋体">1: </font></span><span><font face="新宋体"><span>//按照笔划排序<br><span>2: </span></span><span>select </span><span>* </span><span>from dept order by nlssort</span><span>(</span><span>name</span><span>,</span><span>'NLS_SORT=SCHINESE_STROKE_M'</span></font><span><font face="新宋体">);<br><span>3: </span></font></span><font face="新宋体"><span>//按照部首排序<br><span>4: </span></span><span>select </span><span>* </span><span>from dept order by nlssort</span><span>(</span><span>name</span><span>,</span><span>'NLS_SORT=SCHINESE_RADICAL_M'</span></font><span><font face="新宋体">);<br><span>5: </span></font></span><font face="新宋体"><span>//<strong>按照拼音排序</strong>,此为系统的默认排序方式<br><span>6: </span></span><span>select </span><span>* </span><span>from dept order by nlssort</span><span>(</span><span>name</span><span>,</span><span>'NLS_SORT=SCHINESE_PINYIN_M'</span><span>);</span> </font></span>


注意,该SQL指令并非标准指令,在SQLServer下面的实现方式并不相同。  

把查询出来的人员姓名按照拼音的第一个字母进行排序

select * from ryjbqk where (xm like '%??%' or xm like '%′T%' or xm like '%o?%') and ryid not in(select ryid from rc_zsdj where czt='1') order by nlssort(xm,'NLS_SORT=SCHINESE_PINYIN_M')

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template