ON DELETE CASCADE not working in MySQL

后端 未结 1 1812
耶瑟儿~
耶瑟儿~ 2020-12-21 16:39

I am using the following SQL to create a table named app_info:

CREATE TABLE IF NOT EXISTS `app_info` (
`_id` int(11) NOT NULL AUTO_INCREMENT,
`         


        
相关标签:
1条回答
  • 2020-12-21 17:07

    The MyISAM storage engine doesn't support foreign key constraints. The constraint is parsed but silently ignored.

    To fix your problem use the InnoDB engine instead (for both tables).

    CREATE TABLE ( ... ) ENGINE = InnoDB ... ;
    

    Instead of dropping your tables and recreating them you can also change the storage engine:

    ALTER TABLE myDB.app_info ENGINE = InnoDB;
    ALTER TABLE myDB.tab_info ENGINE = InnoDB;
    

    After changing the engine you will need to add the foreign key constraint again.

    0 讨论(0)
提交回复
热议问题