这是我的第一张表:以下称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在线等.

解决方案 »

  1.   

    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;
      

  2.   

    insert into clientLogTig (tig_clientLog_id,tig_cimusername,tig_username,tig_password,tig_defrayPassWord,tig_buyongyuanyin,tig_tel,tig_createtime)
     values (old......,old....);
    写好具体的字段吧! 按照我写的修改下。
      

  3.   

    把 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)
      

  4.   

    或者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
    //