Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Case-sensitive select statements?
A copy of this was sent to kirk_at_kaybee.org (if that email address didn't require changing) On 15 Feb 2000 15:26:25 GMT, you wrote:
>K Stahl <BlueSax_at_unforgettable.com> wrote:
>:> > where name = upper('Kirk')
>: This could cause problems if there is an index on the column 'name'.
>
>Why? It would slow down the search excessively?
>
No, it wouldn't -- if you did:
where upper(name) = upper('Kirk')
it might. See http://osi.oracle.com/~tkyte/article1/index.html if you have Oracle8i to discover how to create an index on a function and have it be used in a query.
If you have 8.0 or before, a common solution is to create a 'mirror' column and index that. You would alter the table, add a column "UPPER_NAME" and add a trigger to:
...
before insert or update on T for each row
begin
:new.upper_name := upper(:new.name);
end;
Then you can query:
select name from t
where upper_name = upper('Kirk')
>Here is my problem. I want to be able to reproduce their username with
>the same case they entered it in. However, I want it to be case
>insensitive.
>
>I got one useful email, basically (as I'm doing this in a stored
>procedure), I can convert both strings to upper (as the search
>string will be passed in via a parameter):
>
>select * from users where UPPER(name) = UPPER('Kirk')
>
>However, this search would have to be done on every user login. Maybe,
>in this case, it would be more efficient to store their username in the
>database twice: once maintaining case, and once in lower case for
>searches?
-- See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA Opinions are mine and do not necessarily reflect those of Oracle CorporationReceived on Tue Feb 15 2000 - 00:00:00 CST