Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 

 

Oracle case insensitive searches


Oracle Database Tips by Donald Burleson

Oracle and Case Insensitivity

In 10g release 2, we have the option of setting case insensitivity to function with the REGEXP_LIKE function.  Here we show how to take advantage of that powerful new feature.

Setting the Oracle Parameters for case insensitive searching

We need to set NLS_COMP=LINGUISTIC and NLS_SORT=BINARY_CI in order to use 10gR2 case insensitivity.  Since these are session modifiable, it is not as simple as setting them in the initialization parameters. 

We can set them in the initialization parameters but they then only affect the server and not the client side.  The following PL/SQL was used for a search screen:

execute immediate 'alter session set NLS_COMP=LINGUISTIC';

execute immediate  'alter session set NLS_SORT=BINARY_CI';

 Tuning for case insensitive queries:

Depending on the size of the table and type of queries, we may want to build linguistic indexes on the columns to allow case insensitive queries.  This is the sample code for an index:

create index
   nlsci1_gen_person
on
   MY_PERSON
   (NLSSORT
      (PERSON_LAST_NAME, 'NLS_SORT=BINARY_CI')
   )
;

This is a great example of using case insensitive data inside Oracle and creating a case insensitive index to allow queries to me made in initcap, upper or lower, all without invalidating the index. 

Using regexp_like with case insensitive searches:

Here is this example of doing case insensitive searches with regexp_like.  This example of regular expressions such as using regexp_like to return case insensitive results: REGEXP_LIKE(name,'Suzy','i');
 
SQL> select name from names;

NAME
-------------
suzy smith
Suzy Smith
SUZY SMITH
 
 
SQL> alter session set NLS_COMP=ANSI;
SQL> alter session set NLS_SORT=BINARY_CI;

SQL> select name from names where name = 'Suzy Smith'

NAME
-------------
suzy smith
Suzy Smith
SUZY SMITH

*******************************************************
 
So for our example of searching for 'Suzy' and having an NLS_SORT for case sensitive searching (NLS_SORT=BINARY) we could issue the following types of SELECT statements and get the following results:
SQL> select name from names where REGEXP_LIKE(name,'Suzy');

NAME
-----------
Suzy Smith

SQL> select name from names where REGEXP_LIKE(name,'Suzy','i');

NAME
------------
suzy smith
Suzy Smith
SUZY SMITH

Follow the link for information on Late Binding and Runtime Binding in PL/SQL.


support:

For development support just call to gat an Oracle Certified professional for all development projects.

book and code samples:

Easy Oracle
Create Dynamic HTML with Oracle

Includes online code depot

Buy it now for 30% off - Only $19.95 

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.