Re: Foreign key problem
От | Itai Zukerman |
---|---|
Тема | Re: Foreign key problem |
Дата | |
Msg-id | 878zig1wme.fsf@matt.w80.math-hat.com обсуждение исходный текст |
Ответ на | Foreign key problem (Andreas Tille <tillea@rki.de>) |
Ответы |
Re: Foreign key problem
|
Список | pgsql-sql |
Je Mon, 25 Jun 2001 09:34:01 +0200 (CEST), Andreas Tille <tillea@rki.de> scribis: > CREATE TABLE ResKulturDetail > ( > IdLabNr int, > IdIndex smallint > ); > > CREATE TABLE ResKulturDetailDay > ( > IdLabNr int, > IdIndex smallint > ); > > CREATE INDEX IX_IdLabNr_KulturDetail ON ResKulturDetail(IdLabNr) ; > > ALTER TABLE ResKulturDetailDay ADD CONSTRAINT FK_ResKulturDetailDay > FOREIGN KEY (IdLabNr,IdIndex) > REFERENCES ResKulturDetail (IdLabNr,IdIndex) ; > Can anybody explain, why the foreign key constraint fails? According to the documentation for CREATE TABLE: In addition, the referenced columns are supposed to be the columns of a UNIQUE constraint in the referenced table, howeverPostgres does not enforce this. Well, it looks like PostgreSQL *does* enforce it. Try it with: CREATE UNIQUE INDEX IX_IdLabNr_KulturDetail ON ResKulturDetail(IdLabNr, IdIndex) ; I'm not sure why this restriction is necessary... -- Itai Zukerman <http://www.math-hat.com/~zukerman/>
В списке pgsql-sql по дате отправления: