无法使MySQL Trigger工作

时间:2010-12-14 19:23:42

标签: mysql triggers

我写了一个简单的触发器,但它引发了我没有得到的错误。继承人我的触发器:

    CREATE TRIGGER logSlette After DELETE on ansatte
for each row 
begin
insert into slettede_ansatte set AnsattID=old.AnsattID,slettet=now()
end;

表的create table语句是:

    CREATE TABLE slettede_Ansatte
 (
 AnsattID Integer(4) NOT NULL,
 slettet TIME NOT NULL,
 CONSTRAINT Ansatte_PK Primary Key(AnsattID)
 ) ENGINE=INNODB;

1 个答案:

答案 0 :(得分:0)

(修订版)

correct syntax

CREATE TRIGGER logSlette AFTER DELETE ON ansatte
  FOR EACH ROW
  BEGIN
    INSERT INTO slettede_ansatte
       SET AnsattID = OLD.AnsattID,
           slettet=now();
  END;

也许是缺少分号?