简体   繁体   English

mysql中的触发器创建中出现错误“ 1064”?

[英]error “1064” in trigger creation in mysql?

while creating trigger in mysql im getting error 1046. my query is: 在mysql中收到错误1046时创建触发器。我的查询是:

CREATE TABLE test.Employee(
              id            int,
              first_name    VARCHAR(30),
              last_name     VARCHAR(15),
              start_date    DATE,
              end_date      DATE,
              city          VARCHAR(10),
              description   VARCHAR(15)
          );


CREATE TABLE test.Employee_log(
              id int,
              first_name varchar(50),
              last_name varchar(50),
              start_date date,
              end_date date,
              city varchar(50),
              description varchar(50),
              Lasinserted Time
          );

when i am executing below lines it is giving error: 当我执行以下行时,它给出错误:

Error Code : 1064
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 'END$$ 
delimiter' at line 1
(16 ms taken)


delimiter $$
CREATE TRIGGER test.Employee_Trigger
     AFTER insert ON test.employee
     FOR EACH ROW
     BEGIN
     insert into test.employee_log values(new.id,new.first_name,
     new.last_name,new.start_date,new.end_date,
     new.city,new.description,curtime());
    END$$ 
delimiter ;


if some one could please help it would be greately appreciated. 如果有人可以帮助的话,将不胜感激。


Thanks 谢谢
Yugal Yugal

trigger are not routine nor stored procedure, 触发器既不是例程也不是存储过程,
so there is not need for BEGIN...END , plus the table name is case sensitive 因此不需要BEGIN...END ,并且表名区分大小写

CREATE TRIGGER Employee_Trigger
AFTER insert ON Employee
FOR EACH ROW
INSERT INTO test.Employee_log values(new.id,new.first_name,
  new.last_name,new.start_date,new.end_date,
  new.city,new.description,curtime());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM