错误"1064";在mysql中创建触发器? [英] error "1064" in trigger creation in mysql?

查看:191
本文介绍了错误"1064";在mysql中创建触发器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在mysql中创建触发器时出现错误1046.我的查询是:

while creating trigger in mysql i m getting error 1046. my query is:

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.


谢谢
尤加尔(Jugal)


Thanks
Yugal

推荐答案

触发器既不是例程也不是存储过程,
因此不需要BEGIN...END,而且表名区分大小写

trigger are not routine nor stored procedure,
so there is not need for BEGIN...END, plus the table name is case sensitive

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());

这篇关于错误"1064";在mysql中创建触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆