samedi 28 février 2015

error 1215 (hy000) cannot add foreign key constraint - mysql


Vote count:

0




I've googled this error a lot, but no solution found.



CREATE TABLE Student(id VARCHAR(30) NOT NULL, name VARCHAR(150), CONSTRAINT PK1 PRIMARY KEY(id));

CREATE TABLE Course (id VARCHAR(30) NOT NULL, name VARCHAR(150), CONSTRAINT PK2 PRIMARY KEY(id));

CREATE TABLE Enroll(studentId VARCHAR(30) NOT NULL, courseId VARCHAR(30) NOT NULL, PRIMARY KEY(studentId,courseId),
CONSTRAINT FK1 FOREIGN KEY (studentId) REFERENCES Student(id),
CONSTRAINT FK2 FOREIGN KEY (courseId) REFERENCES Course(courseId));


First 2 create statements are fine. 3rd statement generates error:



error 1215 (hy000) cannot add foreign key constraint



Kindly tell what's going wrong? Thanks!



asked 32 secs ago







error 1215 (hy000) cannot add foreign key constraint - mysql

Aucun commentaire:

Enregistrer un commentaire