Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: 10G Case Insensitive Searches.
LineVoltageHalogen wrote:
> If I understand correctly by setting the following:
>
> alter session set nls_comp=ansi;
>
> alter session set nls_sort=binary_ci;
>
> I can issue a query against the database that is case insensitive.
> My question is this: When I test this functionality the index I have in
> place is not longer used for the query? Do I need to create a special
> function based index to speed things up or should the existing index
> (which works if I don't specify the alter sessions) work?
>
> TFD
Yes AFAIK you will need a function based index.
The following test is in 9.2.0.5 and uses "ALTER SESSION SET nls_sort = generic_baseletter" because it works in 9i. I will do a test of binary_ci in 10g if I get a chance.
SQL> CREATE TABLE test_tab
2 AS
3 SELECT DISTINCT object_name AS col FROM all_objects;
Table created.
SQL> INSERT ALL
2 INTO test_tab VALUES ('DATA') 3 INTO test_tab VALUES ('Data') 4 INTO test_tab VALUES ('data')
3 rows created.
Index created.
SQL> SELECT * FROM test_tab WHERE col = 'Data'
2
SQL> @xplan
Predicate Information (identified by operation id):
1 - access("TEST_TAB"."COL"='Data')
SQL> ALTER SESSION SET nls_sort = generic_baseletter;
Session altered.
SQL> ALTER SESSION SET nls_comp = ansi;
Session altered.
Predicate Information (identified by operation id):
1 - filter(NLSSORT("TEST_TAB"."COL")=NLSSORT('Data'))
SQL> ALTER SESSION SET query_rewrite_enabled = TRUE;
Session altered.
SQL> ALTER SESSION SET query_rewrite_integrity = TRUSTED;
Session altered.
SQL> SELECT * FROM test_tab WHERE col = 'Data'
2
SQL> @xplan
| Id | Operation | Name | Rows | Bytes |Cost (%CPU)|
Predicate Information (identified by operation id):
2 - access(NLSSORT("TEST_TAB"."COL")=NLSSORT('Data')) Received on Fri Jul 01 2005 - 10:14:00 CDT
![]() |
![]() |