Re: Constraint to ensure value does NOT exist in another table? - Mailing list pgsql-general

From Simon Riggs
Subject Re: Constraint to ensure value does NOT exist in another table?
Date
Msg-id BANLkTinZK4YoLJBfWbzipY7cgynyiVdKdA@mail.gmail.com
Whole thread Raw
In response to Constraint to ensure value does NOT exist in another table?  (Mike Christensen <mike@kitchenpc.com>)
Responses Re: Constraint to ensure value does NOT exist in another table?
List pgsql-general
On Thu, Jun 16, 2011 at 6:04 AM, Mike Christensen <mike@kitchenpc.com> wrote:

> I know I can setup a FK constraint to make sure Table1.ColA exists in
> Table2.Key, however what if I want to do the reverse?
>
> I want to ensure Table1.ColA does NOT exist in Table2.Key..  Can I do
> this with any sort of CHECK constraint, trigger, custom function, etc?


The most common constraints are provided for, but then after that you
have to use triggers.

PostgreSQL deliberately doesn't support queries in CHECK constraints
for this reason.

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-general by date:

Previous
From: Mike Christensen
Date:
Subject: Re: You could be a PostgreSQL Patch Reviewer!
Next
From: Magnus Hagander
Date:
Subject: Re: Symbols and versioning of binary releases; running a symbol server