【mysql问题】foreign key without name 解决方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a19990412/article/details/83190263

原问题

一开始的输入为

create table sc (sno VARCHAR(7) not null , cno VARCHAR(7) not null, grade VARCHAR(3), primary key(sno, cno), foreign key(sno) references student, foreign key(cno) references course);

后来的修改成功的输入为

create table sc (sno VARCHAR(7) not null , cno VARCHAR(7) not null, grade VARCHAR(3), primary key(sno, cno), foreign key(sno) references student(sno), foreign key(cno) references course(cno));

解释:

  • references需要指定所在表的特定的属性。

猜你喜欢

转载自blog.csdn.net/a19990412/article/details/83190263