MySQL : ERROR 1215 (HY000): Cannot add foreign key constraint

后端 未结 16 1925
误落风尘
误落风尘 2020-11-30 01:37

I have read Database system concepts, 6th edition, Silberschatz. I\'m going to implement the university database system shown in chapter 2 on OS X

16条回答
  •  再見小時候
    2020-11-30 02:12

    I came across the same issue as well. Not sure why this is working but it indeed works: Try add ENGINE INNODB after your create query.

    mysql> create table course
    -> (course_id varchar(7),
    -> title varchar (50),
    -> dept_name varchar(20),
    -> credits numeric(2,0),
    -> primary key(course_id),
    -> foreign key (dept_name) references department) ENGINE INNODB;
    

提交回复
热议问题