删除外键的级联

时间:2011-09-12 11:36:53

标签: mysql foreign-keys

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的行不会被删除

1 个答案:

答案 0 :(得分:4)

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