繁体   English   中英

WordPress级联删除不起作用

[英]WordPress Cascade Deleting doesn't work

我需要数据库帮助。 好的,我正在创建2个这样的表:

CREATE TABLE inventory_category ( 
    id int NOT NULL AUTO_INCREMENT, 
    name varchar(255) NOT NULL, 
    PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

CREATE TABLE inventory_subcategory(
    id int NOT NULL AUTO_INCREMENT,
    category_id int NOT NULL,
    name varchar(255) NOT NULL,
    PRIMARY KEY (id),
    FOREIGN KEY  (category_id) REFERENCES inventory_category(id) ON DELETE CASCADE
) ENGINE=MyISAM DEFAULT CHARSET=utf8

如您所见, category_id引用了inventory_category id 所以,我可以理解,当我将删除的东西inventory_Category ,他的孩子inventory_subcategory会被自动删除? 但这是行不通的。 为什么?

我检查了Mysql.com,看来MyISAM for MySQL或MariaDB不支持外键。

https://dev.mysql.com/doc/refman/5.7/zh-CN/myisam-storage-engine.html

但是,Innodb引擎可能是您想要的:

https://dev.mysql.com/doc/refman/5.7/en/innodb-storage-engine.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM