ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle 字段排序

oracle 字段排序

原创 Linux操作系统 作者:flower1004 时间:2009-06-25 16:36:06 0 删除 编辑

做一个2个数据库间数据比较工具时遇到ORACLE中汉字排序的问题。
使用一下SQL

select *
from T_0303003
order by stock_holder

进行选取数据时(stock_holder为存放中文的字段),结果发现两库返回的记录顺序不一致。琢磨之后应该为字符集问题,一个库字符集为系统默认字符集,另一个库为UTF-8字符集。查找资料后发现,对于中文字段的排序,应该使用以下方式:

-- 按拼音排序 (系统默认)
select *
from T_0303003
order by nlssort(stock_holder,'NLS_SORT=SCHINESE_PINYIN_M');

-- 按部首排序
select *
from T_0303003
order by nlssort(stock_holder,'NLS_SORT=SCHINESE_RADICAL_M');

-- 按笔画排序
select *
from T_0303003
order by nlssort(stock_holder,'NLS_SORT=SCHINESE_STROKE_M');


ORACL官方论坛讨论:
http://www.oracle-database.cn/oracle_database_It-english-database-0-251288.html
Have found a strange question recently, arrange in an order Chinese character order by in oracle, " crocodile's word has been ranked at the end to appear! Whether there is such a situation to know the greater part. Whether it is bug i

-----------------------------------------------------------
NLS _ SORT? ??
answer2:
r> -----------------------------------------------------------
1 perhaps this word is many sound words. 2 says and says according to what way you want to arrange in an order.
ans wer3:

-----------------------------------------------------------
arranges in an order according to the spelling, should need to set up NLS _ SORT. Have Still in test test finish tell and then you body.
answer4:

-----------------------------------------------------------
O In RACLE, arrange in an order question 1. //Arrange in an order 2 according to the stroke. select * from dept order by nlssort(name,NLS _ SORT =SCHINESE _ STROKE _ M); 3.//Press Take the radical and arrange in an order 4. select * from dept order by nlssort(name,NLS _ SORT =SCHINESE _ RADICAL _ M); 5.//Arrange in an order according to the spelling, this arranges in an order the side for systematic acquiescenc Formula 6. select * from dept order by nlssort(name,NLS _ SORT =SCHINESE _ PINYIN _ M); Can revise NLS _ SORT parameter

参考:

http://www.cnblogs.com/heekui/articles/968231.html

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21213917/viewspace-607555/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-06-22

  • 博文量
    6
  • 访问量
    91435