2

I would like to know what is the different between 'in' clause and 'like' clause oracle in check constraint.

here is sample code for 'in' clause

ALTER TABLE EXPREPORT
ADD CONSTRAINT EXPREPORT_CHK1 CHECK 
(EXPREPSTATUS IN ('PENDING', 'APPROVED', 'DENIED'))
ENABLE;

here is sample code for 'like' clause

ALTER TABLE EXPENSEREPORT
ADD CONSTRAINT EXPENSEREPORT_CHK1 CHECK 
(EXPREPSTATUS LIKE 'APPROVED' OR EXPREPSTATUS LIKE 'DENIED' OR EXPREPSTATUS LIKE 'PENDING')
ENABLE;

is there any difference between these two clause?

SQB
  • 3,926
  • 2
  • 28
  • 49
user3051767
  • 55
  • 1
  • 1
  • 4
  • 1
    In this exact case, there should be no difference. If you add wildcards to your strings to match, the difference will be the same as using `LIKE` vs. using `=`. – Joachim Isaksson Nov 30 '13 at 09:54

1 Answers1

0

LIKE column value is similar to specified character(s).

IN column value is equal to any one of a specified set of values.

Click Here for more information about LIKE and IN clause.

KethanKumar
  • 716
  • 5
  • 17
  • In general, yes, `like` and `in` conditions are different, but the way OP is using them (`like` without wildcard characters equal to `=` operator) in his/her example, there is no difference between those two statements. – Nick Krasnov Nov 30 '13 at 09:56
  • I gave one link right. u will get detailed information here. Can u refer once that tutorial. If still u get doubt means will clear it. – KethanKumar Nov 30 '13 at 09:59