nls_sort和nlssort 排序功能介绍
Oracle9i之前,中文是按照二进制编码进行排序的。
在oracle9i中新增了按照拼音、部首、笔画排序功能。设置NLS_SORT值
SCHINESE_RADICAL_M 按照部首(第一顺序)、笔划(第二顺序)排序
SCHINESE_STROKE_M 按照笔划(第一顺序)、部首(第二顺序)排序
SCHINESE_PINYIN_M 按照拼音排序
oracle9i中新增了按照拼音、部首、笔画排序功能
拼音 SELECT * FROM TEAM ORDER BY NLSSORT(列名,'NLS_SORT = SCHINESE_PINYIN_M')
笔划 SELECT * FROM TEAM ORDER BY NLSSORT(列名,'NLS_SORT = SCHINESE_STROKE_M')
部首 SELECT * FROM TEAM ORDER BY NLSSORT(列名,'NLS_SORT = SCHINESE_RADICAL_M')
Oracle9i之前,中文是按照二进制编码进行排序的。在oracle9i中新增了按照拼音、部首、笔画排序功能。
1、设置NLS_SORT参数值
SCHINESE_RADICAL_M 按照部首(第一顺序)、笔划(第二顺序)排序
SCHINESE_STROKE_M 按照笔划(第一顺序)、部首(第二顺序)排序
SCHINESE_PINYIN_M 按照拼音排序
2、Session级别的设置,修改ORACLE字段的默认排序方式:
按拼音:alter session set nls_sort = SCHINESE_PINYIN_M;
按笔画:alter session set nls_sort = SCHINESE_STROKE_M;
按偏旁:alter session set nls_sort = NLS_SORT=SCHINESE_RADICAL_M;
3、语句级别设置排序方式:
按照笔划排序
select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_STROKE_M');
按照部首排序
select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_RADICAL_M');
按照拼音排序,此为系统的默认排序方式
select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_PINYIN_M');
4、修改系统参数(数据库所在操作系统):
set NLS_SORT=SCHINESE_RADICAL_M ;
export NLS_SORT (sh)
setenv NLS_SORT SCHINESE_RADICAL_M (csh)
HKLC\SOFTWARE\ORACLE\home0\NLS_SORT (win注册表)
Oracle 官方说明
NLS_SORT NLS_SORT specifies the collating sequence for ORDER BY queries. NLS_COMPNLS_COMP specifies the collation behavior of the database session.
Property
Description
Parameter type
String
Syntax
NLS_SORT = { BINARY | linguistic_definition }
Default value
Derived from NLS_LANGUAGE
Modifiable
ALTER SESSION
Range of values
BINARY or any valid linguistic definition name
If the value is BINARY, then the collating sequence for ORDER BY queries is based on the numeric value of characters (a binary sort that requires less system overhead).
If the value is a named linguistic sort, sorting is based on the order of the defined linguistic sort. Most (but not all) languages supported by the NLS_LANGUAGE parameter also support a linguistic sort with the same name.
Note:
Setting NLS_SORT to anything other than BINARY causes a sort to use a full table scan, regardless of the path chosen by the optimizer. BINARY is the exception because indexes are built according to a binary order of keys. Thus the optimizer can use an index to satisfy the ORDER BY clause when NLS_SORT is set to BINARY. If NLS_SORT is set to any linguistic sort, the optimizer must include a full table scan and a full sort in the execution plan.
You must use the NLS_SORT operator with comparison operations if you want the linguistic sort behavior.
Property
Description
Parameter type
String
Syntax
NLS_COMP = { BINARY | LINGUISTIC | ANSI }
Default value
BINARY
Modifiable
ALTER SESSION
Basic
No
Values:
BINARY
Normally, comparisons in the WHERE clause and in PL/SQL blocks is binary unless you specify the NLSSORT function.
LINGUISTIC
Comparisons for all SQL operations in the WHERE clause and in PL/SQL blocks should use the linguistic sort specified in the NLS_SORT parameter. To improve the performance, you can also define a linguistic index on the column for which you want linguistic comparisons.
ANSI
A setting of ANSI is for backwards compatibility; in general, you should set NLS_COMP to LINGUISTIC
注意:当使用了NLS_SORT或NLS_COMP,应该指定函数索引来提高数据库性能。如
create index [schema.]indexName on tableName(function(propertyName))
注意:虽然能在oracle查询的时候能用得上,但不知道为什么,当映射到hibernate上时却无效,依然按NLS_SORT=binary排序,不过可以使用@org.hibernate.annotation.OrderBy("nlssort(name,'NLS_SORT=SCHINESE_PINYIN_M')")指定排序方法
nls_sort和nlssort 排序功能介绍的更多相关文章
- Oracle中nlssort()函数排序功能
转自:https://www.iteye.com/blog/libaxiaoyuan-2199851 Oracle9i之前,中文是按照二进制编码进行排序的.在oracle9i中新增了按照拼音.部首.笔 ...
- nlssort排序
ALTER SESSION SET NLS_SORT=''; 排序影响整个会话 Oracle9i之前,中文是按照二进制编码进行排序的. 在oracle9i中新增了按照拼音.部首.笔画排序功能.设置NL ...
- python中列表、元组、字典内部功能介绍
一.列表(list) 常用功能的介绍:
- Python中list的功能介绍
List的功能介绍 1. 列表的两种方法 1. 列表的内置方法 列表的相加 格式:x.__add__(y)等同于x+y 例如:list1 = [1,2,3] print(list1.__add__([ ...
- RDIFramework.NET ━ .NET快速信息化系统开发框架 V3.2->Web版本模块管理界面新增模块排序功能
模块(菜单)的排序是每个系统都必须要有的功能,我们框架模块的排序在业务逻辑中已经体现. WinForm版本可以直接在界面上对模块进行排序以控制模块展示的顺序.Web版本在3.2版本中也新增了直接可以模 ...
- Python实现EXCEL表格的排序功能
EXCEL的数值排序功能还是挺强大的,升序.降序,尤其自定义排序,能够对多个字段进行排序工作. 那么,在Python大法中,有没有这样强大的排序功能呢?答案是有的,而且本人觉得Python的排序功能, ...
- Fiddler抓包使用教程-基本功能介绍
转载请标明出处:http://blog.csdn.net/zhaoyanjun6/article/details/72932886 本文出自[赵彦军的博客] Fiddler 基本页面 会话列表功能介绍 ...
- 性能测试-9.Controller功能介绍
Controller功能介绍 设计场景 配置场景 场景监控 一.设计场景 二.配置场景 规划场景(场景名.调度方式.运行方式.Initialize方式.Start Vusers方式.Duration方 ...
- 通过数据库评估存储设备IO性能-Oracle11gIO校准功能介绍
通过数据库评估存储设备IO性能 ---------Oracle11g IO校准功能介绍 前言 I/O子系统是ORACLE数据库的一个重要组成部分,因为I/O操作是贯穿数据库管理全过程,它操作的对象包括 ...
随机推荐
- iOS 开发中你是否遇到这些经验问题(二)
前言: 1.在Block中一起使用weakSelf与strongSelf的含义 我们都会声明一个弱引用在block中使用, 目的就是防止循环引用, 那么weakSelf与strongSelf一起使用目 ...
- 【转】周末班LR笔记总结—新手入门必备
本来想上传文件的,上传半天没反应,只有这样了,图片不知道能显示不. 上午 学到2012.1.13 七天课 第一天(入门)二.三.四天(VUGEN脚本) 五天(Controller)六天(Analyse ...
- SqlBulkCopy 数据批量操作使用的类
private void SqlBulkCopyByDataTable(string connectionString,string TableName,DataTable dt) { using ( ...
- Java学习步骤
我们为什么选择Java 大多数人选择Java可能只是因为听说Java前景好.Java比较好找工作.Java语言在TIOBE排行榜上一直位于前三等等之类的原因,但是Java具体好在哪里,心里却是没有什么 ...
- JavaScript知识点回顾
一 浏览器对象树 window:处于对象树中的最高层,表示一个浏览器窗口,由于唯一,可以省略不写.(window.document 等价 document) Forms.Images.Links ...
- Map集合的两种遍历方式
Map集合:即 接口Map<K,V> map集合的两种取出方式: 1.Set<k> keyset: 将map中所有的键存入到set集合(即将所有的key值存入到set中) ...
- 1.1、Mybatis一级缓存测试
package me.gacl.test; import me.gacl.domain.User; import me.gacl.util.MyBatisUtil; import org.apache ...
- 【MINA】用mina做业务服之间的通信,实现业务负载均衡思路
学习mina目的还是搭建通信架构,学完mina我们了解了如何实现客户端和服务端,也就是一个正常channel我们是知道怎么建立的 但是问题是,我们应用环境通信分为两种 1.前后端通信 其实这个比较好实 ...
- Apache 流媒体 拖动模块编译
Windows使用apxs独立编译 Apache 模块 http://blog.sina.com.cn/s/blog_43b83d340100mdhl.html 安装 apxs 1.解压apxs.zi ...
- 修改arcgis server默认js和css连接地址
当使用ArcGIS Server 10.1发布了一个地图服务之后,在ArcGIS Server 10.1的机器上使用浏览器进入http://localhost:6080/arcgis/rest/ser ...