Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: creating a foreign key referencing a non-primary key
"Bob Jenkins" <bob_jenkins_at_burtleburtle.net> wrote in message
news:a5d787df.0403180941.15303f98_at_posting.google.com...
> asya_at_bayarea.net (Asya Kamsky) wrote in message
news:<105hh1q6ti25bfb_at_corp.supernews.com>...
> > Is there a way to create a foreign key that references a column
> > that's not a primary key of the other table?
> >
> > (it happens to be part of a composite primary key).
> >
> > Example:
> > t1 (id, version, primary_key (id, version))
> > t2 (t1_id foreign_key on t1(id)) <- not allowed
>
> If you did
> alter table t1 add constraint t1uk unique (id);
> then you could do
> create table t2 (t1_id references t1 (id));
> You can indeed have foreign keys reference unique keys.
You can indeed and I don't know what I was thinking of.
I blame the 'flu.
I have to blame someone!!
Thanks for the correction.
Regards
HJR
Received on Thu Mar 18 2004 - 15:34:08 CST
![]() |
![]() |