Delete SQL record with dependency

0

Good afternoon.

I would like to know how to exclude records from a table containing a foreign key.

I would not like to delete child records (to keep history).

I always get a message warning that there are dependencies when trying to update a parent record.

    
asked by anonymous 31.01.2018 / 17:28

1 answer

2

When you create the foreign key, you can define its behavior when there is a DELETE :

NO ACTION : Deleting the parent record is not allowed. An error message is generated.

CASCADE : The entire line of the child record is erased.

SET NULL : child records are retained, but the value in the column that has the foreign key is set to NULL .

SET DEFAULT : set default value.

If none fits, the solution may be to remove the foreign key or keep a clone table, for history, without a foreign key.

    
31.01.2018 / 19:17