Foreign key not working in MySQL: Why can I INSERT a value that's not in the foreign column?

前端 未结 10 1053
被撕碎了的回忆
被撕碎了的回忆 2020-12-01 02:38

I\'ve created a table in MySQL:

CREATE TABLE actions ( A_id int NOT NULL AUTO_INCREMENT,
type ENUM(\'rate\',\'report\',\'submit\',\'edit\',\'delete\') NOT NU         


        
10条回答
  •  星月不相逢
    2020-12-01 02:48

    Just to save other's of the hours of headache I've been thru - as giraffa touches upon, ensure @FOREIGN_KEY_CHECKS is set to 1.

    SELECT @@FOREIGN_KEY_CHECKS

    SET FOREIGN_KEY_CHECKS=1

提交回复
热议问题