Frank Mash did some testing with triggers and
inspired me to try to create a log table based on triggers. This
also answers his question "After playing earlier with triggers, I
wanted to see whether one can update another table using MySQL
triggers. I tried something like ... but it didn't work. Is it
possible or am I shooting in the dark here?" with a clear
yes!
First I created a data and a log table:
mysql> CREATE TABLE data_table ([Read more]
-> id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> d1 VARCHAR(200) NOT NULL UNIQUE,
-> d2 DECIMAL(9,2) NOT NULL) ENGINE=InnoDB;
Query OK, 0 rows affected (0.02 sec)
mysql> CREATE TABLE log_table (
-> id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> id_data INT UNSIGNED NOT NULL,
-> old_d1 VARCHAR(200) NULL,
…