Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Check constraint

Check constraint

From: Brian Tkatch <SPAMBLOCK.Maxwell_Smart_at_ThePentagon.com.SPAMBLOCK>
Date: Fri, 13 Oct 2000 15:51:44 GMT
Message-ID: <39e72ddd.613222609@news.alt.net>

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 Received on Fri Oct 13 2000 - 10:51:44 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US