首页 文章

mysql错误1215(hy000)无法添加外键约束

提问于
浏览
0

我一直收到这个错误,我对所有表,menuID和customerID使用了InnoDB,它们是各自表中的主键,并且数据类型看起来是相同的 . ERROR 1215(HY000):无法添加外键约束

对不起,如果我遗漏了一些简单的东西,我是mySQL的新手 .

create table customers(
customerID int not null auto_increment primary key,
LastName varchar(255) not null,
FirstName varchar(255) not null,
email varchar(255) not null,
password varchar(255),
phone varchar(255),
creditCard varchar(255),
address varchar(255),
time timestamp)
Engine=InnoDB;

 create table menu(
 menuID int not null auto_increment primary key,
 typeID int,
 itemName varchar(255),
 price varchar(255)) 
Engine=InnoDB;

create table orders(
orderID int not null,
customerID int not null,
menuID int not null,
PRIMARY KEY (orderID, customerID, menuID),
FOREIGN KEY (customerID) REFERENCES customers(customerID) on delete set null on update cascade,
foreign key (menuID) references menu(menuID) on delete set null on update cascade )
Engine=InnoDB;

1 回答

相关问题