Simulate a DELETE CASCADE in MySQL?
问题 Is it possible to predict the operations that follow a DELETE CASCADE automatically? In my software I would like to give the user a warning with details about the data that would be deleted then. 回答1: You can make a copy of the database and put triggers on the after delete DELIMITER $$ CREATE TRIGGER ad_table1_each AFTER DELETE ON table1 FOR EACH ROW BEGIN INSERT INTO log VALUES (null /*autoinc id*/ , 'table1' /*tablename*/ , old.id /*tableid*/ , concat_ws(',',old.field1,old.field2 /*CSV's of