Cannot add foreign key constraignt MySql

假装没事ソ 提交于 2019-12-13 02:21:26

问题


I am creating a database in MySQL for school. It has come up with the error 'cannot add foreign key constraint.' I have looked at other similar questions but cannot find out how it relates to my table. Please help!


回答1:


Update your entries table like so:

CREATE TABLE IF NOT EXISTS entries(
entry_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
exam_date DATE NOT NULL,
student_id INT REFERENCES students(student_id),
subject_id INT REFERENCES subjects(subject_id),
PRIMARY KEY(entry_id)
)


来源:https://stackoverflow.com/questions/35863550/cannot-add-foreign-key-constraignt-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!