table check constraint

From: Robert Schnabel <schnabelr(at)missouri(dot)edu>
To: pgsql-novice(at)postgresql(dot)org
Subject: table check constraint
Date: 2009-05-27 19:03:33
Message-ID: 4A1D8E85.9040909@missouri.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
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.&nbsp; Specifically, what do you
do if you want to allow two non-overlapping ranges?&nbsp; For example, I
need to have everything (&gt;105 AND &lt;199) <b>OR</b> (&gt;202 AND
&lt;900).&nbsp; I read in the docs that using 'between' isn't a good idea so
I did something like the following:<br>
<tt><br>
ALTER TABLE gen000<br>
&nbsp; ADD CONSTRAINT check000 CHECK (sample_id &gt; 105 AND sample_id &lt;
199 <b>OR</b> sample_id &gt; 202 AND sample_id &lt; 900);<br>
<br>
</tt>Will this behave the way it reads or do I need to structure it
differently?<br>
<tt><br>
</tt>Thanks,<br>
Bob<br>
<br>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 847 bytes

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2009-05-27 19:53:05 Re: Query Optimization
Previous Message Zach Calvert 2009-05-27 16:02:46 Re: Query Optimization