Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: using SQL TRIM

Re: using SQL TRIM

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 9 Jul 2001 12:47:53 -0700
Message-ID: <9id1p90261u@drn.newsguy.com>

In article <3B49C0A6.D13A3F98_at_sympatico.ca>, lance says...
>
>if I use SQL command TRIM in a query...will the query still use the
>indexes?
>

Depends.

if you have a

table t ( c varchar2(25) )

and and

index t_idx on t(c)

and go:

select * from t where c = trim( :x );

that'll be able to use the index, however,

select * from t where trim(c) = 'some value'

will not be able to use that index but it could use the index:

index t_idx on t(trim(c));

see
http://osi.oracle.com/~tkyte/article1/index.html for an overview of function based indexes -- the ability to create an index on the trim(c).

--
Thomas Kyte (tkyte@us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Mon Jul 09 2001 - 14:47:53 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US