Is there a way to tune MySQL every time a row changes, then a row is created with another table / database with data initially? (time stamped)
If so, how do I do this?
eg.
UPDATE `live_db`.`people` SET `live_db`.`people`.`name` = 'bob' WHERE `id` = 1;
Makes this happen before the update:
INSERT INTO `changes_db`.`people` SELECT * FROM `live_db`.`people` WHERE `live_db`.`people`.`id` = 1;
And if you did it again, this will lead to something like this:
`live_db`.`people` +----+-------+---------------------+ | id | name | created | +----+-------+---------------------+ | 1 | jones | 10:32:20 12/06/2010 | +----+-------+---------------------+ `changes_db`.`people` +----+-------+---------------------+ | id | name | updated | +----+-------+---------------------+ | 1 | billy | 12:11:25 13/06/2010 | | 1 | bob | 03:01:54 14/06/2010 | +----+-------+---------------------+
The live database must have the created timestamp in the rows, and the change database should have a timestamp when the live DB row was updated. The change database will also not have primary keys and foreign key constraints.
I use InnoDB and MySQL 5.1.49, but I can upgrade if necessary.
source share