删除外键级联

发布于 2024-12-04 01:28:52 字数 537 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

层林尽染 2024-12-11 01:28:52

如果我过时了,有人纠正我,但是 MySQL MyISAM 引擎不处理外键,不是吗?

Somebody correct me if I am out of date, but the MySQL MyISAM engine doesn't deal with Foreign keys does it?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文