sql语句格式:
· 添加外键约束:
alter table 从表 add constraint 外键(形如:FK_从表_主表) foreign key (从表外键字段) references 主表(主键字段);
如果mysql报错:Error Code: 1215. Cannot add foreign key constraint (foreign keys)
检查 主从表两个字段的属性是否一致
sql语句格式:
· 添加外键约束:
alter table 从表 add constraint 外键(形如:FK_从表_主表) foreign key (从表外键字段) references 主表(主键字段);
如果mysql报错:Error Code: 1215. Cannot add foreign key constraint (foreign keys)
检查 主从表两个字段的属性是否一致