Skip to Main Content

SQL & PL/SQL

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!

Contains vs Instr vs Like

K NApr 20 2015 — edited Apr 22 2015

Hi,

Just to understand oracle CONTAINS function, I have created the below table:

create table empmst

( eid number,

ename varchar2(50),

constraint pk_empmst primary key (eid)

)

insert into empmst values (1,'RAVINDRA');

insert into empmst values (2,'JHON')

insert into empmst values (3,'PETER')

insert into empmst values (4,'JHON PETER')

insert into empmst values (5,'JAMES')

insert into empmst values (6,'JHONY')

if I execute

select * from empmst where CONTAINS(ename, 'JAMES', 1) > 0;

getting the error

ORA-20000: Oracle Text error:

DRG-10599: column is not indexed

so i have created index

CREATE INDEX IDX_ENAME ON EMPMST(ENAME) LOGGING NOPARALLEL;

Then also am getting the same error.

and what is the difference among the below statements:

select * from empmst where ename like 'JAMES';

select * from empmst where instr(ename ,'JAMES',1)>0;

select * from empmst where CONTAINS(ename, 'JAMES', 1) > 0;

BANNER

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

PL/SQL Release 10.2.0.1.0 - Production

CORE    10.2.0.1.0    Production

TNS for 32-bit Windows: Version 10.2.0.1.0 - Production

NLSRTL Version 10.2.0.1.0 - Production

Thanks,

Karthik

This post has been answered by Karthick2003 on Apr 20 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 18 2015
Added on Apr 20 2015
3 comments
7,201 views