开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜