Skip to content
Advertisement

Oracle error ORA-02270: no matching unique or primary key for this column-list

I got an error while creating this table.

Here are the course and slide tables:

create table course 
(
    course_num number(10),
    course_name char(10),

    primary key (course_num)
);

create table slide 
(
    serial_no number(10), 
    s_writer char(10),
    s_title char(10), 
    subject char(10),
    regist_num number (10),

    primary key (serial_no, s_writer, s_title),
    foreign key (regist_num) references student(registration_number)
);

What should I do ?

enter image description here

Advertisement

Answer

The foreign key should be in one definition, like this:

create table s_belong_to(
s_serial_no number(10),
writer char(10), 
title char(10), 

foreign key(s_serial_no, writer, title) references slide(serial_no,s_writer, s_title),
primary key (s_serial_no, writer, title)
);
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement