I use this onChange-trigger to log all changes to my mysql database database βhouseβ as the second table house_history (which has exactly the same fields + version identifier).
DELIMITER // CREATE TRIGGER house_change_trigger BEFORE UPDATE ON house FOR EACH ROW BEGIN INSERT INTO house_history ( hnr, top, acc_nr ) VALUES ( OLD.hnr, OLD.top, OLD.acc_nr ); END //
The trigger works, my only problem is that there are 80 fields in the table, and I don't want to list them in the trigger.
The reason when I define additional fields in the table, I want the trigger to copy them as well. And I can also easily copy the trigger to another table after creating the corresponding history table.
Is there a way to copy all the fields of the updated row tables and paste them into the history table (with the same field names)?
source share