数据库已存在表classroom(building,room_no,capacity),现在就是要创建表section;
就出现ERROR 1215 (HY000): Cannot add foreign key constraint 的错误;
原因很简单,设置外键的语法应该是这样的 foreign key (a,b,...) references table_name(a,b,...)
只需将以上语句( foreign key (building,room_no) references classroom)改成 foreign key (building,room_no) references classroom(building,room_no)这样既可!!
在数据创建表时,遇到ERROR 1215 (HY000): Cannot add foreign key constraint 问题
原文:http://www.cnblogs.com/benpaodexiaojue/p/4869141.html