How to change the foreign key referential action? (behavior)

后端 未结 6 607
眼角桃花
眼角桃花 2020-11-27 13:11

I have set up a table that contains a column with a foreign key, set to ON DELETE CASCADE (delete child when parent is deleted)

What would the SQL com

6条回答
  •  广开言路
    2020-11-27 13:39

    Remember that MySQL keeps a simple index on a column after deleting foreign key. So, if you need to change 'references' column you should do it in 3 steps

    • drop original FK
    • drop an index (names as previous fk, using drop index clause)
    • create new FK

提交回复
热议问题