无法添加外键约束MySql [英] Cannot add foreign key constraignt MySql
本文介绍了无法添加外键约束MySql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
更新您的条目
(
entry_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
exam_date DATE NOT NULL,
$ b
CREATE TABLE IF NOT EXISTS b $ b student_id INT参考students(student_id),
subject_id INT REFERENCES主题(subject_id),
PRIMARY KEY(entry_id)
)
pre>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!
解决方案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) )
这篇关于无法添加外键约束MySql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文