Why 'foreign key constraint fails' when foreign key exists?

后端 未结 3 1544
没有蜡笔的小新
没有蜡笔的小新 2021-01-18 07:31

I have a simple query

UPDATE `t_timecard_detail` SET  `timeoff_request_id` = \'adad8e0d-c22b-41c3-a460-6cf982729299\' WHERE `id` = \'cfc7a0a1-4e03-46a4-af89-         


        
相关标签:
3条回答
  • 2021-01-18 07:37

    I think it's a bug. MySQL shouldn't allow You to add FOREIGN KEY referencing to MyISAM table from InnoDB because MyISAM engine isn't transactional, InnoDb is.

    Try:
    ALTER TABLE t_timeoff_request ENGINE=InnoDB;
    
    0 讨论(0)
  • 2021-01-18 07:54

    Maybe the problem is in another table, if you set a constraint on the FK. Did you set up a FK option, like ON UPDATE CASCADE?

    0 讨论(0)
  • 2021-01-18 07:58

    Foreign key constraints can't be applied to MyISAM engine.both table should use innodb engine for supporting foreign key constraints.

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