Re: Foreign Key constraint help!

From: Andrea Mattioli <amattioli_at_gedy.it>
Date: Sat, 19 Dec 1998 14:29:48 +0100
Message-ID: <367BAA4C.965623FD_at_gedy.it>


Have you defined the primary key on table1?

Alter table table1 add primary key (col1,col2);

Dan Hield wrote:

> Using Oracle7, I am trying to create a foreign key on a table which has a
> composite key of three referencing another table which has a composite key
> of two.
>
> i.e.
> table1
> name Null? Type
> col1 not null varchar2(8)
> col2 not null varchar2(50)
> col3 varchar2(3)
> col4 number(3)
> col5 varchar2(2000)
>
> table2
> name Null? Type
> col1 not null varchar2(8)
> col2 not null varchar2(50)
> col3 not null varchar2(50)
>
> I get this error message: 'ORA-02294: cannot add referential constraint -
> paretn keys not found.'
>
> The script I am using to attemp to create the foreign key is as follows:
>
> ALTER TABLE2 ADD CONSTRAINT fk1
> FOREIGN KEY (col1, col2) REFERENCES TABLE1(col1, col2);
>
> Any help greatly appreciated. Keen to learn fast!
>
> Dan.
Received on Sat Dec 19 1998 - 14:29:48 CET

Original text of this message