删除外键级联
CREATE TABLE IF NOT EXISTS `tbl_businessalbum`
(
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`image` varchar(50) NOT NULL,
`businessId` bigint(20) unsigned NOT NULL,
`addedBy_userId` bigint(20) unsigned DEFAULT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
CONSTRAINT fk_businessId FOREIGN KEY(businessId) REFERENCES tbl_business(id)
ON DELETE CASCADE
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
但是,当我从 tbl_business 中删除记录时,包含外键关系(即 tbl_businessalbum 中涉及的数据)的行仍然不会被删除
CREATE TABLE IF NOT EXISTS `tbl_businessalbum`
(
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`image` varchar(50) NOT NULL,
`businessId` bigint(20) unsigned NOT NULL,
`addedBy_userId` bigint(20) unsigned DEFAULT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
CONSTRAINT fk_businessId FOREIGN KEY(businessId) REFERENCES tbl_business(id)
ON DELETE CASCADE
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
But still whn I a delete a record from tbl_business the rows containing data involved in the foreign key relationship i.e from tbl_businessalbum are not deleted
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我过时了,有人纠正我,但是 MySQL MyISAM 引擎不处理外键,不是吗?
Somebody correct me if I am out of date, but the MySQL MyISAM engine doesn't deal with Foreign keys does it?