The most likely issue is this line:
FOREIGN KEY (classLeader) REFERENCES student(studentID),
The datatype of classLeader is VARCHAR(255). That has to match the datatype of the referenced column... student.studentID
. And of course, the student
table has to exist, and the studentID
column has to exist, and the studentID
column should be the PRIMARY KEY of the student table (although I believe MySQL allows this to be a UNIQUE KEY, rather than a PRIMARY KEY, or even just have an index on it.)
In any case, what's missing here is the output from SHOW CREATE TABLE student;
There's a datatype mismatch.
The classLeader VARCHAR(255)
column cannot be a foreign key reference to studentID INT
.
The datatypes of the two columns has to match.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…