事件调度器是Mysql5.1后新增的功能,可以将数据库按自定义的时间周期触发某种操作,可以理解为时间触发器,类似Linux系统下的任务调度器crontab.
CREATE event myevent
on SCHEDULE AT `CURRENT_TIMESTAMP`()+INTERVAL 1 HOUR
DO
UPDATE myschema.mytable set mycol = mycol+1;
create table test(id1 varchar(10),create_time datetime);
create EVENT test_event_1
on SCHEDULE
EVERY 5 SECOND
DO
INSERT INTO test4.test(id1,create_time)
VALUES('test',now());
show events \G
image.png
image.png
show variables like '%scheduler%';
image.png
set global event_scheduler = 1;
image.png
CREATE EVENT truc_test
on SCHEDULE EVERY 1 MINUTE
DO TRUNCATE TABLE test;
--禁用event
alter EVENT test_event_1 DISABLE;
--删除event
DROP test_event_1 ;
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有