Re: CHECK constraint

From: "paul butler" <paul(at)entropia(dot)co(dot)uk>
To: Ben Clewett <B(dot)Clewett(at)roadrunner(dot)uk(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: CHECK constraint
Date: 2003-03-13 14:49:21
Message-ID: 0f5683353140d33PCOW058M@blueyonder.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Date sent: Thu, 13 Mar 2003 14:35:40 +0000
From: Ben Clewett <B(dot)Clewett(at)roadrunner(dot)uk(dot)com>
Copies to: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] CHECK constraint

Ben,
Would foreign keys not be the simplest solution?

CREATE TABLE foo(

id int4 NOT NULL,
FOREIGN KEY (id) REFERENCES bar(id) ON DELETE CASCADE ON UPDATE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE,

)
In SQL standards, I belive a SELECT query is valid in a check constraint:

CREATE TABLE foo (
a INT CHECK ( a IN ( SELECT b FROM bar WHERE .... ) )
}

> However, this seems not to be the case (yet) in PostgreSQL.
>
> Should I do this with Triggers instead? Are there any other elegent
> methods of doing the same?

Ben

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message pcampaigne 2003-03-13 15:08:27 Permission Denied
Previous Message Ben Clewett 2003-03-13 14:35:40 CHECK constraint