我正在爲MySQL中的關聯表編寫腳本,並停止在第二個外鍵約束下編譯;有誰知道什麼可能是錯的?請,我將不勝感激!mysql無法添加2個外鍵
create table Adviser(
AdviserID integer not null,
LastName char(25) not null,
FirstName char(25) not null,
AdviserEmail varchar(100) not null,
OfficePhoneNumber char(12) not null,
constraint Adviser_pk primary key(AdviserID),
constraint Adviser_fk foreign key(OfficePhoneNumber)
references Department(OfficePhoneNumber)
on delete no action
on update no action
);
create table Student(
StudentID integer not null,
LastName char(25) not null,
FirstName char(25) not null,
StudentEmail varchar(100) not null,
EnrollmentDate date not null,
GradDate date not null,
Degree char(25) not null,
DormPhoneNumber char(12) not null,
constraint Student_pk primary key(StudentID),
constraint Student_fk foreign key(DormPhoneNumber)
references Dorm(DormPhoneNumber)
on delete no action
on update no action
);
上方做工精細的兩個表,當我提出以下鏈接表的兩個以上不順心的事與具有2個外鍵
create table AppointmentDate1(
AdviserID integer not null,
StudentID integer not null,
StudentAppointmentDate date not null,
StudentEndDate date not null,
constraint AppointmentDate1_pk primary key(AdviserID, StudentID),
constraint AppointmentDate1_fk foreign key(AdviserID)
references Adviser(AdviserID)
on delete no action
on update no action,
constraint AppointmentDate1_fk foreign key(StudentID)
references Student(StudentID)
on delete no action
on update no action
);
誰能幫助?
你會得到什麼錯誤信息? –