From: | "Florian G(dot) Pflug" <fgp(at)phlo(dot)org> |
---|---|
To: | louis gonzales <gonzales(at)linuxlouis(dot)net> |
Cc: | Wes <wespvp(at)syntegra(dot)com>, pgsql general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Adding foreign key constraints without integrity check? |
Date: | 2006-06-19 22:44:14 |
Message-ID: | 449728BE.4080005@phlo.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | Postg스포츠 토토 사이트SQL |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Casey Duncan | 2006-06-19 22:45:52 | Re: Cannot restart postgres |
Previous Message | Bricklen Anderson | 2006-06-19 22:13:54 | Re: Computing transitive closure of a table |