From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: constraint with check |
Date: | 2010-12-14 07:12:31 |
Message-ID: | ie75cv$9jg$1@reversiblemaps.ath.cx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 2010-12-13, Viktor Bojović <viktor(dot)bojovic(at)gmail(dot)com> wrote:
> --0015175cd20209e2030497532e39
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: quoted-printable
>
> Hi
> im trying to create foreign key constraint which checks not only the
> existence of key in foreign table, but it has to check if node field has
> value=3Dtrue
> but i don't know how to do that, so im asking for help.
> alter table wg.nc
> add CONSTRAINT "nc_fk" FOREIGN KEY ("Id1")
> REFERENCES "wg"."entities"("Id"),
> check (node=3Dtrue)
you can't do that.
add a node column to wg (and a check node is not distinct fron true constaint and default true) then do this
alter table wg.nc
add CONSTRAINT "nc_fk" FOREIGN KEY ("Id1",node)
REFERENCES "wg"."entities"("Id",node);
From | Date | Subject | |
---|---|---|---|
Next Message | emaratiyya | 2010-12-14 07:19:16 | Re: Using count on a join, group by required? |
Previous Message | Lee Hachadoorian | 2010-12-14 05:11:17 | Aggregating by unique values |