Re: Adding foreign key constraints without integrity check?
От | Florian G. Pflug |
---|---|
Тема | Re: Adding foreign key constraints without integrity check? |
Дата | |
Msg-id | 449728BE.4080005@phlo.org обсуждение исходный текст |
Ответ на | Re: Adding foreign key constraints without integrity check? (louis gonzales <gonzales@linuxlouis.net>) |
Ответы |
Re: Adding foreign key constraints without integrity check?
|
Список | pgsql-general |
louis gonzales wrote: > Florian, > Are you certain: > > "You can only create an FK if the fields you are referencing in the > foreign table form a PK there. And creating a PK implicitly creates an > index, which you can't drop without dropping the PK :-(" > Arg.. Should have written "unique index" instead of primary key.. But it doesn't change much, since a unique index and a pk are nearly the same. > I'm not sure I am convinced the necessity of a foreign key, "needing" to > reference a primary keyed entry from a different table. I tried the following: create table a(id int4) ; create table b(id int4, a_id int4) ; alter table b add constraint pk foreign key (a_id) references a (id) ; The alter table gave me an error stating that I need to have a unique index defined on a.id... greetings, Florian Pflug
В списке pgsql-general по дате отправления: