×
☰ See All Chapters

MySQL ON DELETE CASCADE 

Use the ON DELETE CASCADE option if you want rows deleted in the child table when corresponding rows are deleted in the parent table. If you do not specify cascading deletes, the default behavior of the database server prevents you from deleting data in a table if other tables reference it.

If you specify this option, when you delete a row in the parent table, the database server also deletes any rows associated with that row (foreign keys) in a child table. The advantage of the ON DELETE CASCADE option is that it allows you to reduce the quantity of SQL statements needed to perform delete actions.

mysql-on-delete-on-update-cascade-0
 

MySQL ON UPDATE CASCADE 

Use the ON UPDATE CASCADE option if you want rows update in the child table when corresponding rows are updated in the parent table. If you do not specify cascading updates, the default behavior of the database server prevents you from updating data in a table if other tables reference it.

mysql-on-delete-on-update-cascade-1
 

All Chapters
Author