0

How to delete row in table that contain foreign keys to other tables but I don't want that the row in other table deletes, so I cant make use of CASCADE?

How can I do that?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
afsane
  • 1,889
  • 6
  • 25
  • 40

2 Answers2

1

SET NULL instead of CASCADE.

David Wick
  • 7,055
  • 2
  • 36
  • 38
  • That's pretty awesome. I just never thought of trying it, because its obviously impossible. –  Jun 21 '11 at 04:12
  • it shows me this error: [Err] 1005 - Can't create table '.\rts\#sql-22c_49.frm' (errno: 121) – afsane Jun 21 '11 at 04:30
0

If table has foreigh key it means that it is a child table; in this case you can delete rows with DELETE statement, parent table won't be modified.

Devart
  • 119,203
  • 23
  • 166
  • 186
  • oh no! i want delete row from parent table, no child! i want when i delete parent nothing happen to child . – afsane Jun 21 '11 at 09:21