From: | Jayadevan M <maymala(dot)jayadevan(at)gmail(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Inheritance and foreign keys |
Date: | 2017-05-25 11:48:59 |
Message-ID: | CAFS1N4gPH0ihnhxvtTETL_cvwsR_nhLocr6S=BHc03YKAnR67A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I designed three tables so that one table inherits another, and the third
table references the parent table. If a record is inserted into the third
table and the value does exist in the parent table indirectly, because it
is present in the inherited table, I still get an error.
Is some option available while creating the foreign key so that it will
consider the data in the child tables also while doing a constraint
validation?
create table myt(id serial primary key);
create table mytc (like myt);
alter table mytc inherit myt;
insert into myt values(1);
insert into mytc values(2);
select * from myt;
id
----
1
2
create table a (id integer references myt(id));
insert into a values(2);
ERROR: insert or update on table "a" violates foreign key constraint
"a_id_fkey"
DETAIL: Key (id)=(2) is not present in table "myt".
Regards,
Jayadevan
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Kretschmer | 2017-05-25 12:10:00 | Re: Inheritance and foreign keys |
Previous Message | anthonymarc | 2017-05-25 10:06:51 | Buy counterfeit money ( morganmoore401@gmail.com )euros,dollars,pounds, SAR,ZAR,AED |