Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1954

Triggers - History table (1 reply)

$
0
0
Hi all,

I would like to create a single table which will be used as a history table for any inserts, updates, deletes to all other tables in the DB, without using PHP.

For example.
id, table, old, new, timestamp, user


Using triggers, is there a way to serialise the contents of the OLD and NEW rows so they can be entered into the history table?

Can you create a trigger which will run on any update to any table? If yes, then can you reference the table it is actually amending? If not, then I'll have to create a trigger for each table.

User will come from the NEW record, which will have a last_edited_by field set.

Viewing all articles
Browse latest Browse all 1954

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>