Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Check constraint
Brian Tkatch wrote:
>
> I have a column that must = 1 or 0. SO I want to add a constraint
>
> CHECK (Flag IN (1,2)).
>
> 1) Does that exclude NULLs?
>
> 2) Are there any differences, speed or otherwise between
> CHECK (Flag IN (1,2)).
> and CHECK ((Flag = 1) OR (Flag = 2)).
> I'm assuming it would be negligable, but I'm curious.
>
> ============
>
> I have two columns, and for legacy purposes they must work with each
> other.
>
> If Flag = 1, The_Date must be null
> If Flag = 0, The_Date nmust not be null
>
> I've added two constraints to check this
>
> The_Date_NOT_NULL CHECK ( NOT ((Flag = 0) AND (The_Date IS NULL))
>
> The_Date_NULL CHECK ( NOT ((Flag = 1) AND (The_Date IS NOT NULL))
>
> I though an exclusive or would be better, but I could not find such an
> operator for PL/SQL. Is there one?
>
> Brian
Nulls will still be allowed unless the column is set as NOT NULL.
HTH
-- =========================================== Connor McDonald http://www.oracledba.co.uk (faster/mirrored at http://www.oradba.freeserve.co.uk) Its not the voices in my head that bother me... its the voices in yours.Received on Fri Oct 13 2000 - 05:38:25 CDT
![]() |
![]() |