oracle 字段排序

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

None.gif select *
None.gif
from T_0303003
None.gif
order by stock_holder

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

None.gif -- 按拼音排序 (系统默认)
None.gif
select *
None.gif
from T_0303003
None.gif
order by nlssort(stock_holder, ' NLS_SORT=SCHINESE_PINYIN_M ' );
None.gif
None.gif
-- 按部首排序
None.gif
select *
None.gif
from T_0303003
None.gif
order by nlssort(stock_holder, ' NLS_SORT=SCHINESE_RADICAL_M ' );
None.gif
None.gif
-- 按笔画排序
None.gif
select *
None.gif
from T_0303003
None.gif
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博客 ” ,链接:http://blog.itpub.net/21213917/viewspace-607555/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/21213917/viewspace-607555/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值