create table a
( a varchar(10),
c varchar(10),
d varchar(10),
primary key (a,c));
表a已成功创建...
create table b
(
a varchar(10),
c varchar(10),
d varchar(10),
primary key(a),
foreign key(a) references a(a),
foreign key(c) references a(c)
);
ERROR 1215(HY000):无法添加外键约束
无法创建表b
答案 0 :(得分:1)
尝试:
foreign key(a,c) references a(a,c)
此外,最好为约束命名:
constraint <name> foreign key(a,c) references a(a,c)