开发者

How to delete a row from Parent table without delete a row from Child table

开发者 https://www.devze.com 2023-02-18 02:42 出处:网络
I want to delete开发者_JAVA技巧 a row from Parent table without deleting or modifying row in the child table. For this what type referential integrity constraints of mysql i have to use.Could you expl

I want to delete开发者_JAVA技巧 a row from Parent table without deleting or modifying row in the child table. For this what type referential integrity constraints of mysql i have to use.


Could you explain the reason why you would need such a scenario?

I would consider flagging the parent row as deleted as opposed to "deleting" them permanently.


Updated: sorry, I was wrong...

Don't set referential integrity at all.

Cascade will delete children when deleting parent. Restrict will throw mySQL error. Set Null will set foreign key value in child table/tables to NULL. No Action according to this will be equivalent to Restrict.

0

精彩评论

暂无评论...
验证码 换一张
取 消