mysql创建触发器报错

山城忙碌人 2010-02-03 03:45:38
这是我的第一张表:以下称A
create table clientLog
(id int primary key auto_increment,cimusername varchar(20),
username varchar(50),
password varchar(50),defrayPassWord varchar(50),
tel varchar(30),createtime timestamp default CURRENT_TIMESTAMP,
updatecreatetime varchar(30),buyongyuanyin varchar(300));


这是我的第一张表:以下称B
create table clientLogTig(id int primary key auto_increment,tig_clientLog_id int, tig_cimusername varchar(50),
tig_username varchar(50),tig_password varchar(50),tig_defrayPassWord varchar(50),
tig_buyongyuanyin varchar(50),tig_tel varchar(50) ,tig_createtime timestamp default CURRENT_TIMESTAMP);


数据库mysql.我想在表A做修改操作的时候把原来的数据保存在B表中.我创建触发器如下:
create trigger tigBisu
after
update on clientLog for each row
begin
insert into clientLogTig values(null,old.id,old.cimusername,old.username,old.password,old.defrayPassWord,old,buyongyuanyin,old.tel)
end;


但会出错,望高手们指教下.注:数据库里没有任何触发器.
出错如下:
you have an error in your SQL syntax;check the manual that corresphonds to your mysql server varsion for the right syntax to use near 'insert into clientLogTig values(null,old.id,old.cimusername,old.username,old.pas'line 5

在线等.
...全文
169 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ACMAIN_CHM 2010-02-03
  • 打赏
  • 举报
回复
或者

delimiter //

create trigger tigBisu after update on clientLog
for each row
begin
insert into clientLogTig values(null,old.id,old.cimusername,old.username,old.password,old.defrayPassWord,old,buyongyuanyin,old.tel);
end
//

ACMAIN_CHM 2010-02-03
  • 打赏
  • 举报
回复
把 begin end 去掉

create trigger tigBisu after update on clientLog
for each row
insert into clientLogTig values(null,old.id,old.cimusername,old.username,old.password,old.defrayPassWord,old,buyongyuanyin,old.tel)
懒得去死 2010-02-03
  • 打赏
  • 举报
回复
insert into clientLogTig (tig_clientLog_id,tig_cimusername,tig_username,tig_password,tig_defrayPassWord,tig_buyongyuanyin,tig_tel,tig_createtime)
values (old......,old....);


写好具体的字段吧! 按照我写的修改下。
vipper23 2010-02-03
  • 打赏
  • 举报
回复
create trigger tigBisu
after
update on clientLog for each row
insert into clientLogTig select null,old.id,old.cimusername,old.username,old.password,old.defrayPassWord,old,buyongyuanyin,old.tel;

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧