Skip site navigation (1) Skip section navigation (2)

CHECK Constraints

From: "Van Ingen, Lane" <lvaningen(at)ESNCC(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: CHECK Constraints
Date: 2005-04-22 16:02:41
Message-ID: A3FF4275060B76459B5C08A64AE330C805C2ED@twmail.esncc.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi all,
  the 8.0 manual says CHECK can be used in the following manner:
       CHECK (expression)
The only stipulations are that it must produce a boolean result (true or unknown) to succeed. 
 
If I were to specify a the following on a field named price in one expression, would it succeed?
     CHECK (price = 1 OR price = 2 OR price = 3)
 
In other words, I would want to raise an exception on any other value other than 1, 2, or 3. Can
this be done? All of the examples in the manual show a single check (like price > 0) .

Responses

pgsql-novice by date

Next:From: Walker, Jed SDate: 2005-04-22 16:11:00
Subject: Re: Authorized privileges when calling a procedure
Previous:From: Bruno Wolff IIIDate: 2005-04-22 15:14:18
Subject: Re: Granting permission on a sequence to a group

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group