create trigger insert_a after insert on A1 for each row insert into trace values (‘A1‘,‘INSERT‘,NOW(),substring_index(current_User(),‘@‘,1),substring_index(current_User(),‘@‘,-1));
4:插入测试数据
mysql> insert into A values(1); Query OK, 1 row affected (0.00 sec)
mysql> select * from trace; +--------+----------+---------------------+----------+-----------+ | tbname | DML_type | DML_time | DML_user | DML_IP | +--------+----------+---------------------+----------+-----------+ | A | INSERT | 2010-11-29 17:58:12 | root | localhost | +--------+----------+---------------------+----------+-----------+ 1 row in set (0.00 sec)
mysql> select * from trace; +--------+----------+---------------------+----------+--------------+ | tbname | DML_type | DML_time | DML_user | DML_IP | +--------+----------+---------------------+----------+--------------+ | A | INSERT | 2010-11-29 17:58:12 | root | localhost | | A | INSERT | 2010-11-29 17:58:38 | cpc | 192.168.0.30 | +--------+----------+---------------------+----------+--------------+ 2 rows in set (0.00 sec)