I have a MySQL-table that's accessed from different APIs. I would like to log when any rows are deleted from this table. Is this possible?
Yes, you can use a simple trigger, something like;
CREATE TRIGGER data_delete BEFORE DELETE ON data FOR EACH ROW
BEGIN
INSERT INTO log(logmessage) VALUES (CONCAT('Delete of value ', OLD.id));
END
A simple SQLfiddle demo.
Yes it is possible. You have to use trigger for this purpose. Using triggers you can save the data, time and other information after the delete occurs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With