ok, i tried
1) create a table for the logging
CREATE TABLE `LOGGING` (
`id` bigint(20) NOT NULL auto_increment,
`table` varchar(20) default NULL,
`username` varchar(20) default NULL,
`logtime` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2) create a script which will create the triggers (in this example i use my 'test' database...
#!/bin/bash
echo "DELIMITER ;;" >tmp.sql
for f in `mysqlshow test | sed -e 's/|//g' | grep -v '-'`;
do
echo 'CREATE TRIGGER t_'$f' AFTER INSERT ON '$f' FOR EACH ROW BEGIN insert into LOGGING (`table`, `username`, `logtime`) values ("'$f'",CURRENT_USER(), NOW()); end ;; ' >>tmp.sql ;
done
echo "DELIMITER ;" >>tmp.sql
3) its a quick and dirty script, so you have to delete some lines from the tmp.sql script...
at least the 1st three lines, and the line that whould create a trigger for the 'logging' table....
4) when you think its OK, you can execute this script to create the triggers in your database...
5) this works for INSERTS, you have to tweak this do the same for UPDATES and DELETES....