Does CASCADE Delete execute as transaction?

cascade, sql

Solution

In general¹, yes, cascade deletes are done in the same transaction (or subtransaction) as your original delete. You should read the documentation of your SQL server, though.

¹ The exception is if you're using a database that doesn't support transactions, like MySQL with MyISAM tables.

Problem

I want to perform cascade delete for some tables in my database, but I'm interested in what happens in case there's a failure when deleting something. Will everything rollback?

Original source