1

我一直收到一条错误消息,外键引用列表中的列数不等于引用列表中的列数。

这是我得到错误的那一行。

      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
);
4

1 回答 1

1

您只需要员工的主键:

foreign key(EID) references employee
于 2012-09-10T20:41:52.880 回答