Database Audit Trail
Posted: 2014-04-18 12:43
I found this.. https://www.simple-talk.com/sql/databas ... dit-trail/
It is a way to use sql server commands and program a trigger to create an audit trail for tracking changes to all tables. I just want to track changes to 3 tables. I also want to only log the changed data, not everything. Currently I have hook code in tablename_after_insert, tablename_after_update, and tablename_after_delete for it to track changes and it is working. It will not log old data but it does log all the new data.
I really want this to be a cleaner process. I want to do the audit like in POP's article above in the same database with a new table called audit or historical log.. using a trigger I can do this.. my problem for not being able to copy and paste this code from Pop's article above (see link at top) right into a trigger and do this is that I have shared hosting, my sql database is accessed through phpmyadmin and it won't take sql server commands in the sql tab, just basic sql.
In PHPMyAdmin I can create a trigger but never done it before. Not sure what goes in the big box.. ok with choosing the options though.
The tables I want to track are bus_status, compliance and routes
and I want to track only the data that is changed. Right now I have it tracking everything which is making the audit table I have temporarily working quite large. Not good.
If it will only capture the changed data it would be so small as we don't do many transactions per day (like 20 total for all users) so it would be great.
Your thoughts on how best to do that?
It is a way to use sql server commands and program a trigger to create an audit trail for tracking changes to all tables. I just want to track changes to 3 tables. I also want to only log the changed data, not everything. Currently I have hook code in tablename_after_insert, tablename_after_update, and tablename_after_delete for it to track changes and it is working. It will not log old data but it does log all the new data.
I really want this to be a cleaner process. I want to do the audit like in POP's article above in the same database with a new table called audit or historical log.. using a trigger I can do this.. my problem for not being able to copy and paste this code from Pop's article above (see link at top) right into a trigger and do this is that I have shared hosting, my sql database is accessed through phpmyadmin and it won't take sql server commands in the sql tab, just basic sql.
In PHPMyAdmin I can create a trigger but never done it before. Not sure what goes in the big box.. ok with choosing the options though.
The tables I want to track are bus_status, compliance and routes
and I want to track only the data that is changed. Right now I have it tracking everything which is making the audit table I have temporarily working quite large. Not good.
If it will only capture the changed data it would be so small as we don't do many transactions per day (like 20 total for all users) so it would be great.
Your thoughts on how best to do that?