0
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

为什么是这样?

4

1 回答 1

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
于 2012-11-26T07:23:26.193 回答