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

Home -> Community -> Usenet -> c.d.o.server -> Re: Q:check constraint question ?

Re: Q:check constraint question ?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Thu, 20 Jan 2000 11:53:59 -0500
Message-ID: <79fe8s0fdkpqtdbtfhqparkjaf0tcj31d9@4ax.com>


A copy of this was sent to tedchyn_at_yahoo.com (if that email address didn't require changing) On Thu, 20 Jan 2000 14:45:27 GMT, you wrote:

>Sir, how do i create table with following constraint ?
>
>two columns(c1 number,c2 number) and check constraint is c2=0 when c1=1.
>thanks in advance
>Ted Chyn
>

create table t
( c1 number,
  c2 number,
  check ( (c2=0 and c1=1) or (c1 is null or c1 <> 1) ) )
/

should do it

>
>Sent via Deja.com http://www.deja.com/
>Before you buy.

--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Thu Jan 20 2000 - 10:53:59 CST

Original text of this message

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