ORACLE中文字段排序

做一个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

posted on 2007-11-22 10:21  网际浪人  阅读(3334)  评论(0编辑  收藏  举报