MySQL InnoDB constraint does not work

前端 未结 1 1109
青春惊慌失措
青春惊慌失措 2021-01-25 08:37

I stumble upon strange behavior with innoDB constraint, and cannot find cause of it.
I have tables with data.
Below listed their structures:


CREATE TABL         


        
相关标签:
1条回答
  • 2021-01-25 09:07

    If a call was made to

    SET FOREIGN_KEY_CHECKS=0;
    

    then FK checks are turned off. Who knows, that may be the state of your system right now. Have them turned on with

    SET FOREIGN_KEY_CHECKS=1;
    

    Note the following. Just turning checks back on does not re-validate the referential integrity. One needs ALTER TABLE for that.

    Simply publishing a schema does little to say you are safeguarded.

    Meaning, I could turn off my constraints, use the system, delete some data, do LOAD DATA INFILE (in short mess up my data), then run off to Stackoverflow with a schema and say "gosh how did this happen".

    And it doesn't matter what state your system is in now. It matters what it was in back then.

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