Re: CHECK constraint - Mailing list pgsql-novice

From paul butler
Subject Re: CHECK constraint
Date
Msg-id 0f5683353140d33PCOW058M@blueyonder.co.uk
Whole thread Raw
In response to CHECK constraint  (Ben Clewett <B.Clewett@roadrunner.uk.com>)
Responses Re: CHECK constraint  (Ben Clewett <B.Clewett@roadrunner.uk.com>)
List pgsql-novice
Date sent:          Thu, 13 Mar 2003 14:35:40 +0000
From:               Ben Clewett <B.Clewett@roadrunner.uk.com>
Copies to:          pgsql-novice@postgresql.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@postgresql.org)

pgsql-novice by date:

Previous
From: Ben Clewett
Date:
Subject: CHECK constraint
Next
From: Bruno Wolff III
Date:
Subject: Re: Version Number