ORACLE中文字段排序

简介: 做一个2个数据库间数据比较工具时遇到ORACLE中汉字排序的问题。 使用一下SQL select * from T_0303003 order by stock_holder 进行选取数据时(stock_holder为存放中文的字段),结果发现两库返回的记录顺序不一致。

做一个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:
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
目录
相关文章
|
11月前
|
SQL Oracle 关系型数据库
Oracle 将表中的数据查出更改某一字段的值后再插入该表
Oracle 将表中的数据查出更改某一字段的值后再插入该表
205 2
|
11月前
|
SQL Oracle 关系型数据库
Oracle之如何限制字段内数据的录入
Oracle之如何限制字段内数据的录入
133 0
|
1月前
|
存储 Oracle 关系型数据库
【YashanDB 知识库】YMP 校验从 yashandb 同步到 oracle 的数据时,字段 timestamp(0) 出现不一致
在YMP校验过程中,从yashandb同步至Oracle的数据出现timestamp(0)字段不一致问题。原因是yashandb的timestamp(x)存储为固定6位小数,而Oracle的timestamp(0)无小数位,同步时会截断yashandb的6位小数,导致数据差异。受影响版本:yashandb 23.2.7.101、YMP 23.3.1.3、YDS联调版本。此问题会导致YMP校验数据内容不一致。
|
1月前
|
存储 Oracle 关系型数据库
【YashanDB 知识库】YMP 校验从 yashandb 同步到 oracle 的数据时,字段 timestamp(0) 出现不一致
【YashanDB 知识库】YMP 校验从 yashandb 同步到 oracle 的数据时,字段 timestamp(0) 出现不一致
|
1月前
|
存储 Oracle 关系型数据库
【YashanDB知识库】YMP校验从yashandb同步到oracle的数据时,字段timestamp(0)出现不一致
【YashanDB知识库】YMP校验从yashandb同步到oracle的数据时,字段timestamp(0)出现不一致
|
11月前
|
DataWorks Oracle 关系型数据库
DataWorks操作报错合集之尝试从Oracle数据库同步数据到TDSQL的PG版本,并遇到了与RAW字段相关的语法错误,该怎么处理
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
171 0
|
11月前
|
存储 Oracle 关系型数据库
oracle 过滤字段中的中文,不再洋不洋土不土
oracle 过滤字段中的中文,不再洋不洋土不土
241 0
|
11月前
|
存储 Oracle 安全
Oracle 12c的不可见字段:数据的“隐形斗篷”
【4月更文挑战第19天】Oracle 12c引入了不可见字段,这是一种隐藏数据列的特性,用于增强数据安全性和实现业务逻辑。不可见字段在常规查询中不显示,但参与数据操作,适合存储敏感信息或内部元数据。创建时只需在列定义中指定“INVISIBLE”属性。虽然有其限制,如特定查询可能暴露,但正确使用能有效提升数据安全性。了解和利用这一功能对数据管理员至关重要。
|
11月前
|
Oracle 关系型数据库 数据安全/隐私保护
oracle 19c 密码字段
oracle 19c 密码字段
90 0
|
11月前
|
Oracle 关系型数据库 数据库
Flink Sink to Oracle 存在字段CLOB类型,如何处理错误”ORA-01461: 仅能绑定要插入LONG的LONG值“
做Flink CDC同步数据过程中,目标是Oracle数据库,其中某个字段较大被设置为CLOB类型,其中会遇到异常,”ORA-01461: 仅能绑定要插入LONG的LONG值“