Re: Foreign Key constraint help!

From: Dan Hield <dan.hield_at_cwcom.net>
Date: Sat, 19 Dec 1998 18:09:41 -0000
Message-ID: <367beb13.0_at_news1.mcmail.com>


Yes, I have created the primary keys on both tables sucessfully, hence 'not null' values in table description. This is why it puzzles me.

Andrea Mattioli wrote in message <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 - 19:09:41 CET

Original text of this message