2012-09-10 69 views
1

我一直收到一個錯誤,指出外鍵引用列表中的列數不等於引用列表中的列數。oracle引用列的數量必須與引用列匹配

這是我得到的錯誤。

 foreign key(EID, Lastname, Firstname, Midinitial) references employee, 

有誰知道爲什麼我得到這個錯誤?

create table employee(
    EID varchar(20) primary key, 
    Lastname varchar(20), 
    Firstname varchar(20), 
    Midinitial char(1), 
    gender char(1), 
    street varchar(20), 
    city varchar(20) 
); 

create table works(
    EID varchar(20) primary key, 
    Lastname varchar(20), 
    Firstname varchar(20), 
    Midinitial char(1), 
    company_name varchar(20), 
    salary numeric(5,0), 
    foreign key(EID, Lastname, Firstname, Midinitial) references employee, 
    foreign key(company_name) references company 
); 

create table company(
    company_name varchar(20) primary key, 
    city varchar(20), 
    foreign key(city)references employee 
); 

回答

1

你需要從只有員工的主鍵:

foreign key(EID) references employee 
相關問題