【开源中国 APP 全新上线】“动弹” 回归、集成大模型对话、畅读技术报告”
问题!有两个库!库中表结构相同,db1中各个表多出一个status列!有个需求,根据db1里面表中的status=1的值插入到db2中想同的表中!
我感觉触发器能够实现!但是写了一点,老出错!可能是我水平有限!希望各位能看看是不是我写的触发器有问题!
delimiter $$
create trigger db1.tr_tb1 after update on db1.tb1
begin
declare tem_id int;
declare tem_stus enum enum;
select @tem_id=tb1.id,@tem_stus=ststus from db1.tb1 where tb1.tatus=new.status;
if @tem_stus=1 then
insert into db2.tb1 select id,status from db1.tb1 where tb1.id=@tem_id;
end if;
end$$