Running MySQL audit using a trigger with mappings

When looking at similar issues such as:

Get trigger to insert changed column values ​​into audit table only

Audit logging strategies

I would like to take this step further and compare the updated data to see if it has actually been updated ... I'm not sure if this is the ideal solution (performance).

Background:

We have some data that is periodically updated by the user.

When this data is updated, I would like to compare what they have presented with what already exists and what they have submitted to make sure that there has been a change.

If there are changes, proceed to write the audit record to the Central Audit History table outlining the changed fields.

Thoughts / ideas? I did my best to search but didn't have much luck. I'll be happy to delete this question if it's a duplicate.

Thanks!

0


a source to share


1 answer


You can write a trigger BEFORE UPDATE

where you use aliases OLD

and NEW

in your trigger to compare the values ​​available in the pre-update record with the values ​​you are updating. Depending on the result of the comparison, you can write an entry to your audit table.



+1


a source







All Articles