1. 程式人生 > >oracle查詢區分大小寫

oracle查詢區分大小寫

ORACLE預設所存的值是取分大小寫的,但有些需求想忽略大小寫,今天就淺談一下nls_sort ,nls_comp實現查詢忽略大小寫查詢

  1. [email protected]select * from testci ;   
  2.         ID NAME                 REMARK   
  3. ---------- -------------------- --------------------
  4.          1 a                    lower code   
  5.          1 A                    upper code   
  6. [email protected]select * from testci wherename='a';   
  7.         ID NAME                 REMARK   
  8. ---------- -------------------- --------------------
  9.          1 a                    lower code   
  10. [email protected]select * from  v$nls_parameters where parameter ='NLS_SORT';   
  11. PARAMETER                         VALUE   
  12. -------------------------------- ----------------
  13. NLS_SORT                          BINARY
  14. [email protected]ALTER SESSION SET NLS_SORT='BINARY_CI';   
  15. Session altered.   
  16. [email protected]select * from testci wherename='a';   
  17.         ID NAME                 REMARK   
  18. ---------- -------------------- --------------------
  19.          1 a                    lower code   
  20. [email protected]select * from  v$nls_parameters where parameter ='NLS_COMP';   
  21. PARAMETER                         VALUE   
  22. ---------------------------------- ------------------
  23. NLS_COMP                          BINARY
  24. [email protected]ALTER SESSION SET NLS_COMP=LINGUISTIC;   
  25. Session altered.   
  26. [email protected]select * from testci wherename='a';   
  27.         ID NAME                 REMARK   
  28. ---------- -------------------- --------------------
  29.          1 a                    lower code   
  30.          1 A                    upper code  
[email protected]> select * from testci ;

        ID NAME                 REMARK
---------- -------------------- --------------------
         1 a                    lower code
         1 A                    upper code

[email protected]> select * from testci where name='a';

        ID NAME                 REMARK
---------- -------------------- --------------------
         1 a                    lower code

[email protected]> select * from  v$nls_parameters where parameter ='NLS_SORT';

PARAMETER                         VALUE
-------------------------------- ----------------
NLS_SORT                          BINARY

[email protected]> ALTER SESSION SET NLS_SORT='BINARY_CI';

Session altered.

[email protected]> select * from testci where name='a';

        ID NAME                 REMARK
---------- -------------------- --------------------
         1 a                    lower code

[email protected]> select * from  v$nls_parameters where parameter ='NLS_COMP';

PARAMETER                         VALUE
---------------------------------- ------------------
NLS_COMP                          BINARY

[email protected]> ALTER SESSION SET NLS_COMP=LINGUISTIC;

Session altered.

[email protected]> select * from testci where name='a';

        ID NAME                 REMARK
---------- -------------------- --------------------
         1 a                    lower code
         1 A                    upper code

NLS_COMP:
確定資料庫中值的比較,10G中增加了LINGUISTIC,根據nls_sort引數指定進行比較,用來取代ansi,但ANSI為了向後相容保留,還有一個值是BINARY根據字元的二進位制值比較也是預設值,總共三個值

note:To improve the performance, you can also define a linguistic index on the column for which you want linguistic comparisons.

nls_sort:
指定order by 的查詢順序,If the value is BINARY, then the collating sequence for ORDER BY queries is based on the numeric value of characters.

note: 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.

值非常多,可以通過V$NLS_VALID_VALUES where parameter=’SORT’ 查詢

不過修改任何引數都要考慮效能問題

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.
因篇幅原因 就說這些,其實與這兩個引數相關的還有很多…

相關推薦

oracle查詢區分大小寫

ORACLE預設所存的值是取分大小寫的,但有些需求想忽略大小寫,今天就淺談一下nls_sort ,nls_comp實現查詢忽略大小寫查詢 [email protected]> select * from testci ;           ID NA

mysl查詢區分大小寫

public function handle($params) { $page = $params['page_no'] ? : 1; $pagesize = 10; $pagebeigin = ($page-1) * $pa

mysql查詢區分大小寫

mysql在預設情況下查詢時欄位的值是不區分大小寫的。 select * from t_xx where name='Abc' 和  select * from t_xx where name='ABC' 的查詢結果是一樣的。 但在某些場景下這是不符合我們的需求的,我們可以修改我們需要區分大小的表進

SQL查詢區分大小寫方法

 一、例項介紹 SQL語句大小寫到底是否區分呢?我們先從下面的這個例子來看一下: 例: --> 建立表,插入資料: declare @maco table (number int,myvalue varchar(2)) insert into @maco sel

Laravel模糊查詢區分大小寫

Laravel的ORM特殊操作! 舉個例子:我們資料庫設計的編碼方式如果是ci,也就是說大小寫不敏感的話,我們搜尋的時候,搜尋test,那麼結果是Test,test,teST等等都出來,但是我們加上l

MYSQL 查詢區分大小寫方法

mysql查詢預設是不區分大小寫的 如: select  * from  table_name where  a like  'a%'    select  * from  table_name where  a like  'A%'    select * from tab

SQLite查詢區分大小寫

android預設資料庫是SQLite,使用查詢語句預設不區分大小寫,可能導致查詢結果字串匹配出錯,PRAGMA命令是SQLite的特殊命令,使用此命令可以區分大小寫:String sql = "PRAGMA case_sensitive_like = 1"//或者是true

oracle資料庫不區分大小寫查詢

為了在查詢時,使查詢結果不區分大小寫,一般將搜尋條件以及查詢結果集同時轉為大寫,或者小寫,然後進行查詢:如下:在下表中,查詢欄位(TRIM_COl)中包含aaa(不區分大小寫)的結果集,sql如下:查詢結果:同時轉為小寫的sql如下:

Oracle 查詢區分大小寫 (正則函式)

//不區分大小寫查詢  REGEXP_LIKE(欄位名, '(" + keyword+ ")', 'i') " ); Oracle中的Like操作符使用'_'和'%'作為萬用字元,使用就像這樣: SELECT name FROM test_like WHERE nam

【MySQL】如何解決MySQL中查詢區分大小寫的問題

bsp title 標識 article ble 問題 col bold table mysql查詢默認是不區分大小寫的 如: select * from some_table where str=‘abc‘; select * from some_ta

mysql表名等大小寫敏感問題、字段類型timestamp、批量修改表名、oracle查詢歷史操作記錄等

table 時間 lar 內容 sele values 當前日期 load 兩個 mysql表名等大小寫敏感問題:http://blog.csdn.net/postnull/article/details/72455768; 1 MySQL在Linux下數據庫名、表名、

轉!!mysql 查詢條件不區分大小寫問題

har bin class 區分大小寫 發現 IT server2 nbsp 情況 做用戶登錄模塊時,輸入用戶名(大/小寫)和密碼 ,mysql都能查出來。-- mysql查詢不區分大小寫。 轉自 http://blog.csdn.net/qishuo_java/art

oracle 區分大小寫遇到的坑

1. oracle 欄位是區分大小寫的 。。在navicat 中使用查詢    select REMAIN_PRINCIPAl from T_NF_PROJECT;    navicat 預設會把 REMAIN_PRINCIPAl 轉換成大寫去查詢 ,就是 

mogodb不區分大小寫查詢

菜鳥教程-mogodb學習 一、不區分大小寫的正則表示式 如果檢索需要不區分大小寫,我們可以設定 $options 為 $i。 以下命令將查詢不區分大小寫的字串 runoob: >db.posts.find({post_text:{$regex:"runoob",$opti

mysql查詢區分大小寫

摘自:http://www.jb51.net/article/70884.htm 當我們輸入不管大小寫都能查詢到資料,例如:輸入 aaa 或者aaA ,AAA都能查詢同樣的結果,說明查詢條件對大小寫不敏感。 解決方案一: 於是懷疑Mysql的問題。做個實驗:直接使用客戶端用sql查詢

mysql區分大小寫查詢

(在彈幕關鍵詞查詢表情符號時用到了) <select id="getCountByKeyword" resultType="java.lang.Long"> SELECT COUNT(id) FROM

grep不區分大小寫查詢字串方法

版權宣告:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/yanlaifan/article/details/52766109 grep不區分大小寫查詢字串方法     grep用來過濾字串資訊,grep預設對字母大小寫敏感,不過可以通過

如何設定Sql Server資料庫查詢區分大小寫和全形半形

開發中常用的資料庫有Oracle和Sql Server,Oracle資料庫在查詢的時候是有大小寫區分的,而Sql Server資料庫則不區分大小寫,如何使Sql Server資料庫在查詢時有大小寫的區分呢?下面我們就來總結一下: 要想設定Sql Server資料庫區

編寫查詢條件不區分大小寫的SQL語句!

1、先將資料庫中該欄位全部轉為大寫,然後用Upper()函式將條件轉為大寫: select * from code_table_data t where Upper(t.DETAIL_DESC)=Upper('tr');   2、 模糊查詢:在Java中將條件轉為大寫,然後將該

oracle 11g使用者名稱密碼區分大小寫

在oracle 11g中建立了使用者名稱和密碼,登陸的時候怎麼登陸都登陸不上,後來上網查了一下竟然是因為使用者名稱和密碼區分大小寫的緣故。對於oracle 11g以前的版本來說,使用者名稱和密碼不區分大小寫,從oracle 11g開始使用者名稱和密碼是預設區