Solved

Case insensitive search in Oracle

Posted on 2003-10-30
7
1,104 Views
Last Modified: 2010-05-18
I know string data comparision in Oracle is case sensitive. Is there a way where can eliminate case sensitive compariision? (we are using 9i)
0
Comment
Question by:rsastry
7 Comments
 
LVL 7

Accepted Solution

by:
grim_toaster earned 125 total points
ID: 9649396
You can convert both strings to upper/lowercase and then do the comparison.  The only thing to watch out for is when you want to use a normal index on the column, as calling a function on it would prevent its use (however, you can use function-based indexes).
0
 

Author Comment

by:rsastry
ID: 9649472
Thanks. Is there a way where we can change server setting without touching the code? (Instead of using upper functions and function based indexes) or is there an option during database install to select case insensitive comparision?
0
 
LVL 7

Assisted Solution

by:Bigfam5
Bigfam5 earned 125 total points
ID: 9649493
Basically the answer is no, but if your app allows for mixed case to be entered then you would have to address that during comparisons

Select * from my_table   where upper(Col1) = 'ABC' ;
OR
Select * from my_table   where lower(Col1) = 'abc';

But like suggested above, create a function based index on Col1

create index idx_my_table_1 on my_table ( upper(Col1) );
OR
create index idx_my_table_1 on my_table ( lower(Col1) );



0
 
LVL 7

Expert Comment

by:Bigfam5
ID: 9649533
Well, if you don't want to touch the code you could always create triggers

create or replace trigger on trg_my_table
before insert or update on my_table
for each row
begin
 :new.Col1 := upper(:new.Col1);
end;
/

0
 
LVL 15

Expert Comment

by:andrewst
ID: 9649566
Yes, you are looking for a feature that SQL Server has (I believe), but unfortunately for you, Oracle does not.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Stay Alert! 13 62
CREATE TABLE syntax 4 45
Maintaining Oracle Managed Accounts 2 20
sql query 9 21
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now