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

Re: CHECK Constraints

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "Van Ingen, Lane" <lvaningen(at)ESNCC(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: CHECK Constraints
Date: 2005-04-22 16:37:05
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
On Fri, Apr 22, 2005 at 12:02:41 -0400,
  "Van Ingen, Lane" <lvaningen(at)ESNCC(dot)com> wrote:
> 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) .

Yes, you can do that.

In response to

pgsql-novice by date

Next:From: Walker, Jed SDate: 2005-04-22 16:47:06
Subject: Re: Granting permission on a sequence to a group
Previous:From: Michael FuhrDate: 2005-04-22 16:19:28
Subject: Re: CHECK Constraints

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