Recommended Example of Using Wildcards with Escaped Terms in Oracle Text Queries

(Doc ID 1307213.1)

Last updated on SEPTEMBER 29, 2014

Applies to:

Oracle Text - Version to [Release 8.1.7 to 12.1]
Information in this document applies to any platform.
***Checked for relevance on 06-Feb-2013***


An Oracle Text query which includes escape characters for reserved words with wildcard characters return results which at first glance might look incorrect, but are the result of consistent behavior.

Consider the following example:

create table test(text varchar2(20));
insert into test values('ABC TR AZ DEF');
insert into test values('ABC TR DEF');
insert into test values('ABCTRDEF');
create index test_idx on test(text) indextype is ctxsys.context;

TR is a reserved word, so any query on a phrase that includes a whitespace delimited TR will fail unless that phrase or term is escaped out using the escape characters { }.

Using wildcards around a phrase may not return the intended match, e.g.:

select * from test where contains(text,'%{C TR D}%')>0;

nor will putting wildcards inside the braces:

select * from test where contains(text,'{%C TR D%}')>0;


Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms