create table branch(
brname char(20) not null,
city char(20) not null,
assests float(8,2) not null,
locid int not null,
coname char(20) not null,
primary key(coname,brname)
)engine=innodb;
alter table branch
add constraint fk_branch_city foreign key(coname,locid)
references city(coname,locid);
create table room(
brname char(20) not null,
roomnb int not null,
costofroom float(8,2) not null,
roomsize int not null,
roomfloor int not null,
primary key(roomnb,brname)
)engine=innodb;
alter table room
add constraint fk_room_branch foreign key(brname)
references branch(brname);
我得到错误:sql执行错误1215,无法添加外部约束键(alter table room until branch(brname);正在突出显示)。 所以我只是不明白我该如何解决这个问题。