CREATE TRIGGER Tr1
AFTER DELETE ON Table1
REFERENCING
OLD TABLE AS OldTable,
NEW TABLE AS NewTable
FOR EACH STATEMENT
产生以下错误:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REFERENCING
OLD TABLE AS OldTable,
NEW TABLE AS NewTable
为什么会这样?
答案 0 :(得分:0)
如果要查看旧表,则应创建BEFORE DELETE触发器 -
CREATE TRIGGER Tr1
BEFORE DELETE
ON Table1
FOR EACH ROW
BEGIN
...
SET @old_count = NULL;
SELECT COUNT(*) INTO @old_count FROM Table1;
...
END