CREATE TABLE annuaire (
annu_id serial NOT NULL,
annu_category int4 NOT NULL DEFAULT 0,
CONSTRAINT annu_pk1 PRIMARY KEY (annu_id)
) WITH OIDS;
CREATE TABLE users (
annu_id int4 NOT NULL,
annu_login char(20) NOT NULL,
CONSTRAINT annu_un1 UNIQUE (annu_login)
) INHERITS (annuaire);
CREATE TABLE newstheme (
nwth_id serial NOT NULL,
nwth_label1 varchar NOT NULL,
CONSTRAINT nwth_pk1 PRIMARY KEY (nwth_id)
) WITH OIDS;
CREATE TABLE nwannutheme (
nwan_annuid int4 NOT NULL,
nwan_nwthid int4 NOT NULL,
CONSTRAINT nwan_fk1 FOREIGN KEY (nwan_annuid) REFERENCES
annuaire(annu_id) ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE
INITIALLY IMMEDIATE,
CONSTRAINT nwan_fk2 FOREIGN KEY (nwan_nwthid) REFERENCES
newstheme(nwth_id) ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE
INITIALLY IMMEDIATE,
CONSTRAINT nwan_pk1 PRIMARY KEY (nwan_annuid,nwan_nwthid)
) WITH OIDS;
testdb=# select * from users;
annu_id | annu_category | annu_login
---------+---------------+----------------------
3 | 1 | toto
4 | 4 | titi
(2 rows)
Ceci étant posé, voici le problème rencontré, lorsque j'insère dans
nwannutheme un annuid qui est dans annuaire mais pas dans users,
insert into nwannutheme (nwan_annuid,nwan_nwthid) values(2,1);
ça fonctionne,
si annuid est dans users,
insert into nwannutheme (nwan_annuid,nwan_nwthid) values(3,1);
j'ai le message :
ERROR: nwan_fk2 referential integrity violation - key referenced from
nwannutheme not found in annuaire
Question, y a-t-il une solution pour gérer les clefs étrangères d'une
table héritée ?
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Nicolas Kowalski
Rue des Prairies writes:
Bonjour,
Bonjour.
[...]
Question, y a-t-il une solution pour gérer les clefs étrangères d'une table héritée ?
Non, je ne crois pas malheureusement.
À la fin de la page de doc qui va bien (http://www.postgresql.com/docs/7.4/interactive/ddl-inherit.html), on peut lire ceci:
" A limitation of the inheritance feature is that indexes (including unique constraints) and foreign key constraints only apply to single tables, not to their inheritance children. Thus, in the above example, specifying that another table's column REFERENCES cities(name) would allow the other table to contain city names but not capital names. This deficiency will probably be fixed in some future release. "
-- Nicolas
Rue des Prairies <nospam@wanadoo.fr> writes:
Bonjour,
Bonjour.
[...]
Question, y a-t-il une solution pour gérer les clefs étrangères d'une
table héritée ?
Non, je ne crois pas malheureusement.
À la fin de la page de doc qui va bien
(http://www.postgresql.com/docs/7.4/interactive/ddl-inherit.html), on
peut lire ceci:
"
A limitation of the inheritance feature is that indexes (including
unique constraints) and foreign key constraints only apply to single
tables, not to their inheritance children. Thus, in the above example,
specifying that another table's column REFERENCES cities(name) would
allow the other table to contain city names but not capital
names. This deficiency will probably be fixed in some future release.
"
Question, y a-t-il une solution pour gérer les clefs étrangères d'une table héritée ?
Non, je ne crois pas malheureusement.
À la fin de la page de doc qui va bien (http://www.postgresql.com/docs/7.4/interactive/ddl-inherit.html), on peut lire ceci:
" A limitation of the inheritance feature is that indexes (including unique constraints) and foreign key constraints only apply to single tables, not to their inheritance children. Thus, in the above example, specifying that another table's column REFERENCES cities(name) would allow the other table to contain city names but not capital names. This deficiency will probably be fixed in some future release. "
-- Nicolas
Rue des Prairies
Nicolas Kowalski a écrit :
Rue des Prairies writes:
Bonjour,
Bonjour.
[...]
Question, y a-t-il une solution pour gérer les clefs étrangères d'une table héritée ?
Non, je ne crois pas malheureusement.
À la fin de la page de doc qui va bien (http://www.postgresql.com/docs/7.4/interactive/ddl-inherit.html), on peut lire ceci:
" A limitation of the inheritance feature is that indexes (including unique constraints) and foreign key constraints only apply to single tables, not to their inheritance children. Thus, in the above example, specifying that another table's column REFERENCES cities(name) would allow the other table to contain city names but not capital names. This deficiency will probably be fixed in some future release. "
Too bad, merci néanmoins pour ta réponse
Olivier.
Nicolas Kowalski a écrit :
Rue des Prairies <nospam@wanadoo.fr> writes:
Bonjour,
Bonjour.
[...]
Question, y a-t-il une solution pour gérer les clefs étrangères d'une
table héritée ?
Non, je ne crois pas malheureusement.
À la fin de la page de doc qui va bien
(http://www.postgresql.com/docs/7.4/interactive/ddl-inherit.html), on
peut lire ceci:
"
A limitation of the inheritance feature is that indexes (including
unique constraints) and foreign key constraints only apply to single
tables, not to their inheritance children. Thus, in the above example,
specifying that another table's column REFERENCES cities(name) would
allow the other table to contain city names but not capital
names. This deficiency will probably be fixed in some future release.
"
Question, y a-t-il une solution pour gérer les clefs étrangères d'une table héritée ?
Non, je ne crois pas malheureusement.
À la fin de la page de doc qui va bien (http://www.postgresql.com/docs/7.4/interactive/ddl-inherit.html), on peut lire ceci:
" A limitation of the inheritance feature is that indexes (including unique constraints) and foreign key constraints only apply to single tables, not to their inheritance children. Thus, in the above example, specifying that another table's column REFERENCES cities(name) would allow the other table to contain city names but not capital names. This deficiency will probably be fixed in some future release. "