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

From Igor Neyman
Subject Re: Constraint to ensure value does NOT exist in another table?
Date
Msg-id F4C27E77F7A33E4CA98C19A9DC6722A207AB3A4A@EXCHANGE.corp.perceptron.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

-----Original Message-----
From: Mike Christensen [mailto:mike@kitchenpc.com]
Sent: Thursday, June 16, 2011 1:05 AM
To: pgsql-general@postgresql.org
Subject: Constraint to ensure value does NOT exist in another table?

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?
 Thanks!

Mike


Trigger (with corresponding trigger function) will definitely do the
job.

Regards,
Igor Neyman

pgsql-general by date:

Previous
From: Rick Harding
Date:
Subject: Re: trouble building user defined agg function with plpython
Next
From: Scott Ribe
Date:
Subject: Re: No implicit index created when adding primary key with ALTER TABLE