ALTER SESSION SET NLS_SORT=''; 排序影响整个会话 
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 排序功能介绍的更多相关文章

  1. Oracle中nlssort()函数排序功能

    转自:https://www.iteye.com/blog/libaxiaoyuan-2199851 Oracle9i之前,中文是按照二进制编码进行排序的.在oracle9i中新增了按照拼音.部首.笔 ...

  2. nlssort排序

    ALTER SESSION SET NLS_SORT=''; 排序影响整个会话 Oracle9i之前,中文是按照二进制编码进行排序的. 在oracle9i中新增了按照拼音.部首.笔画排序功能.设置NL ...

  3. python中列表、元组、字典内部功能介绍

    一.列表(list) 常用功能的介绍:

  4. Python中list的功能介绍

    List的功能介绍 1. 列表的两种方法 1. 列表的内置方法 列表的相加 格式:x.__add__(y)等同于x+y 例如:list1 = [1,2,3] print(list1.__add__([ ...

  5. RDIFramework.NET ━ .NET快速信息化系统开发框架 V3.2->Web版本模块管理界面新增模块排序功能

    模块(菜单)的排序是每个系统都必须要有的功能,我们框架模块的排序在业务逻辑中已经体现. WinForm版本可以直接在界面上对模块进行排序以控制模块展示的顺序.Web版本在3.2版本中也新增了直接可以模 ...

  6. Python实现EXCEL表格的排序功能

    EXCEL的数值排序功能还是挺强大的,升序.降序,尤其自定义排序,能够对多个字段进行排序工作. 那么,在Python大法中,有没有这样强大的排序功能呢?答案是有的,而且本人觉得Python的排序功能, ...

  7. Fiddler抓包使用教程-基本功能介绍

    转载请标明出处:http://blog.csdn.net/zhaoyanjun6/article/details/72932886 本文出自[赵彦军的博客] Fiddler 基本页面 会话列表功能介绍 ...

  8. 性能测试-9.Controller功能介绍

    Controller功能介绍 设计场景 配置场景 场景监控 一.设计场景 二.配置场景 规划场景(场景名.调度方式.运行方式.Initialize方式.Start Vusers方式.Duration方 ...

  9. 通过数据库评估存储设备IO性能-Oracle11gIO校准功能介绍

    通过数据库评估存储设备IO性能 ---------Oracle11g IO校准功能介绍 前言 I/O子系统是ORACLE数据库的一个重要组成部分,因为I/O操作是贯穿数据库管理全过程,它操作的对象包括 ...

随机推荐

  1. DBCP数据源

    DBCP数据源是Apache软件基金组织下的开源连接池实现,需要两个jar文件:Commons-dbcp.jar 连接池的实现和Commons-pool.jar 连接池实现的依赖库

  2. Android自定义标题TitleView

    Android开发过程中,经常遇到一个项目需要重复的定义相同样式的标题栏,Android相继推出了actionBar, toolBar, 相信有用到的朋友也会遇到一些不如意的时候,比如标题栏居中时,需 ...

  3. SQL Server I/O 问题的诊断分

    一. SQL Server 什么时候和磁盘打交道: 1. SQL 需要访问的数据没有在Buffer pool中,第一次访问时需要将数据所在的页面从数据文件中读取到内存中.(只读) 2. 在insert ...

  4. linux基于file的logger

    我们可能会遇到这样的问题:即写出的代码可能需要编译成动态连接库并在不同运行环境下运行,而这些运行环境下log的输出方式可能不同,一种运行环境的log方式在另一种运行环境下可能无法输出.而为保证多种运行 ...

  5. 配置Linux数据转发(给其他接口转发一个接口的internet网络)

    配置Linux数据转发 [主机]第一步开启转发net.ipv4.ip_forward = 1echo "1" > /proc/sys/net/ipv4/ip_forward第 ...

  6. angularjs Failed to read the 'selectionStart' property from 'HTMLInputElement':

    在找angularjs input(type='number')在获取焦点的时候,文本框内容选中效果,参考了:Select text on input focus,我直接复制他的code之后,在ion ...

  7. requirejs 定义模块中含有prototype

    因为我对requirejs不熟悉,不清楚如何定义带有prototype的模块, 在看了:https://gist.github.com/jonnyreeves/2474026 的demo之后,就明白了 ...

  8. [转载][jQuery] Cannot read property ‘msie’ of undefined错误的解决方法

    参考 [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法 ---------------------------------------- ...

  9. C#下利用封包、拆包原理解决Socket粘包、半包问题(新手篇)

    介于网络上充斥着大量的含糊其辞的Socket初级教程,扰乱着新手的学习方向,我来扼要的教一下新手应该怎么合理的处理Socket这个玩意儿. 一般来说,教你C#下Socket编程的老师,很少会教你如何解 ...

  10. postgresql crosstab 行转列函数

    http://blog.csdn.net/hexin373/article/details/19242833