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

我一直收到这个错误,我对所有表,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;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值