DROP TABLE IF EXISTS test ;
CREATE TABLE test (iss int);
delimiter $$
CREATE TRIGGER trIn
AFTER INSERT ON test
FOR each ROW
BEGIN
IF (select count(*) from information_schema.tables where table_name='xxx')=0
THEN
SET @n=1; ----你要做的操作
ELSE
SET @n=2; ----这里你可以随意写个东西 反正就是不触发本来的操作
END IF ;
END;
$$
delimiter ;
--test
mysql> set @N=0;
Query OK, 0 rows affected (0.00 sec)
mysql> create table xxx(a int);
Query OK, 0 rows affected (0.01 sec)
mysql> insert test select 1;
Query OK, 1 row affected (0.04 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> select @n;
+------+
| @n |
+------+
| 2 |
+------+
1 row in set (0.00 sec)
|