table check constraint - Mailing list pgsql-novice

From Robert Schnabel
Subject table check constraint
Date
Msg-id 4A1D8E85.9040909@missouri.edu
Whole thread Raw
List pgsql-novice
I'm trying to add range check constraints to tables but I'm not 100%
sure I'm doing it correctly for one of them.  Specifically, what do you
do if you want to allow two non-overlapping ranges?  For example, I
need to have everything (>105 AND <199) OR (>202 AND
<900).  I read in the docs that using 'between' isn't a good idea so
I did something like the following:

ALTER TABLE gen000
  ADD CONSTRAINT check000 CHECK (sample_id > 105 AND sample_id <
199 OR sample_id > 202 AND sample_id < 900);

Will this behave the way it reads or do I need to structure it
differently?

Thanks,
Bob

pgsql-novice by date:

Previous
From: Zach Calvert
Date:
Subject: Re: Query Optimization
Next
From: Tom Lane
Date:
Subject: Re: Query Optimization