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: Creating Contraint using sql

Re: Creating Contraint using sql

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/09/19
Message-ID: <34238246.86584151@newshost>#1/1

On Thu, 18 Sep 1997 20:12:40 -0500, Gary England <gengland_at_hiwaay.net> wrote:

>Cuong Quyen Truong wrote:
>>
>> Does anyone know how to make constraint between relations. For example
>> Relation A has attributes a1(NUMBER) a2(NUMBER) and Relation B has
>> attribures b1(NUMBER) b2(NUMBER) then I would like to make a contraint
>> which say that if a1=b1 then a2 must be > b2.
>
>One way is with a database trigger that is fired on insert/update
>commands to abort the action if the contraint is violated.

or use the following create table:

create table foo

( a1    number,
  a2    number,
  b1    number,
  b2    number,

  constraint My_Rule check (( a1 = b1 AND a2 > b2 ) or ( a1 <> b1 ) ) )
/

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD

http://govt.us.oracle.com/ -- downloadable utilities



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Fri Sep 19 1997 - 00:00:00 CDT

Original text of this message

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