mysql中创建触发器,当更新表的一条数据后,触发事件-更新另一表的数据。 使用实例:触发器用处还是很多的,比如校内网、开心网、Facebook,你发一个日志,自动通知好友,其实就是在增加日志时做一个后触发,再向通知表中写入条目 无 drop table if exists ta
mysql中创建触发器,当更新表的一条数据后,触发事件->更新另一表的数据。drop table if exists tab1; create table tab1 ( tab1_id int ) drop table if exists tab2; create table tab2 ( tab2_id int )
drop trigger if exists t_afterUpdate_on_tab1;
create trigger t_afterUpdate_on_tab1 after update on tab1 for each row
begin
insert into tab2 values(new.tab1_id);
end;
drop trigger if exists t_afterDelete_on_tab1; create trigger t_afterDelete_on_tab1 after delete on tab1 for each row begin delete from tab2 where tab2_id = old.tab1_id; end;
drop procedure if exists bach_insert_tab1;
delimiter|
create procedure bach_insert_tab1()
begin
declare v int default 0;
while v<100
do
insert into tab1 values(v);
set v=v+1;
end while;
end;
|
delimiter;
-- 调用存储过程
call bach_insert_tab1();
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号