Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up cascading deletes in MySQL workbench?

In MySQL Workbench, how do you set up a cascading delete on a relationship?

I clicked the relationship line and clicked on properties but I do not see any mention of a cascading delete option.

like image 581
MadSeb Avatar asked Feb 09 '12 23:02

MadSeb


People also ask

How do I use cascade delete in MySQL?

ON DELETE CASCADE constraint is used in MySQL to delete the rows from the child table automatically, when the rows from the parent table are deleted. For example when a student registers in an online learning platform, then all the details of the student are recorded with their unique number/id.

How do I set up delete cascade?

Use the ON DELETE CASCADE option to specify whether you want rows deleted in a 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.

Does MySQL support cascade delete?

CASCADE : Delete or update the row from the parent table and automatically delete or update the matching rows in the child table. Both ON DELETE CASCADE and ON UPDATE CASCADE are supported.

How does cascade work in MySQL?

MySQL ON UPDATE CASCADE ON UPDATE CASCADE clause in MySQL is used to update the matching records from the child table automatically when we update the rows in the parent table.


1 Answers

Right Click On Table -> Alter Table -> Foreign Keys Tab

Look at the upper-right corner "Foreign Key Options", there are two drop down boxes, one is to specify the delete action: "On Delete"

enter image description here

like image 161
J Cooper Avatar answered Oct 31 '22 14:10

J Cooper