Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Curly Brace with contains - oracle text searching

user-270z1Feb 20 2023 — edited Feb 21 2023

All, Oracle novice here, so bear with me…

I'm trying to understand how Oracle text searching works (contains(myCol, ‘%abc%’) > 0). I've searched the web but can't seem to find ANTHING that will satisfy my inquiry. I'm interested in escaped characters using curly braces. For example: What is the difference among the 3 search queries below:

First, create table and insert values & index:

create table myTABLE(myCOL varchar2(25));
insert into myTABLE(myCOL ) values ('def');
insert into myTABLE(myCOL ) values ('cdef');
insert into myTABLE(myCOL ) values ('abcdefg');

create index myINDEX on myTABLE(myCOL )
indextype is CTXSYS.CONTEXT

  1. select * from myTABLE where CONTAINS(myCOL , '%def%') > 0;
  2. select * from myTABLE where CONTAINS(myCOL , '%{def}%') > 0;
  3. select * from myTABLE where CONTAINS(myCOL , '{%def%}') > 0;

From my view, #1 appears to be a legitimate wildcard situation (results will be “def”, “cdef”, “abcdefg”). #2 would appear to be identical to #1 (there are no special characters or operators to escape, therefore it should read similar to #1 and return the same results). For #3, Oracle would ignore the percent signs and the results would be “def” only (which brings up the question: If the ‘%’ signs are inactive then the query should be looking for the literal string ‘%def%’, which should return nothing).

What am i missing here? Thanks for any help.

Comments
Post Details
Added on Feb 20 2023
3 comments
318 views