当前位置:网站首页>MySQL event_single event_timed loop event
MySQL event_single event_timed loop event
2022-08-09 09:11:00 【Hu Letian】
事件简介
MySQL自5.1Version introduction event,i.e. in fixed events,Do one fixed thing,And you can also decide that this thing is only executed once,It is also executed in a loop at a fixed interval.Along with the database visualization software more and more,There are many ways to create events,在这里,The two most commonly used are introduced,第一种,代码方式,第二种,使用NavicatCreated visually.
代码方式
-- 查看定时器是否开启,OFF为关
show variables like 'event_scheduler'
-- 开启定时任务,After this way is turned on,Database restart will automatically close
set global event_scheduler=1
-- 创建定时任务
create event lock_rpt
on schedule every 10 second
do
update rpt_template set report_status=1 where rpt_template_id in ('000','1B87483969B9431090F925E789F7C41A')
-- 定时任务格式
create event 事件名称
on schedule every 间隔时间
do
具体执行的SQL任务语句
-- 修改定时任务
alter event lock_rpt
on schedule every 20 second
do
update rpt_template set report_status=1 where rpt_template_id = '000'
-- Modify the scheduled task format
alter event 事件名称
on schedule every 间隔时间
do
具体执行的SQL任务语句
-- View specified events
show events
-- 或
select * from mysql.event
-- Closes the scheduled task for the specified event
alter event lock_rpt on completion preserve disable
-- 关闭定时器
set global event_scheduler = 0
*开启事件
The above opens the event,数据库重启后,The event button closes automatically,如果想永久改变,参考鸡蛋(我大学室友)写的:
https://blog.csdn.net/qq_38134242/article/details/114300600?spm=1001.2014.3001.5501
中的1.2.2
可视化方式
1.使用Navicat,Select the corresponding database,右击事件,新建事件
2.Double-click the event to open it,Write what the event needs to execute in the definitionSQL
3.Set the execution start time and frequency of this event,最后保存,保存的时候,The name to enter for this event
4.Where events are actually stored(MySQL数据库中的event表)
边栏推荐
- 编程memonic chant、trick
- parse <compoN> error: Custom Component‘name should be form of my-component, not myComponent or MyCom
- 奥维地图电脑端手机端不能用了,有没有可替代的地图工具
- 多维度LSTM(长短期记忆)神经网络预测未来存款余额走势
- canal工作原理及简单案例演示
- When and How to use MALLOC
- 按字节方式和字符方式读取文件_加载配置文件
- gin中改进版curd接口例子
- makefile的foreach、filter、filter-out函数
- canvas 文字垂直居中
猜你喜欢
随机推荐
【环境搭建】onnx-tensorrt
【培训课程专用】RPC模型:代码导读
关于指针、地址的大小的问题(以及malloc的用法)
算术表达式求值演示
define 可变参数定义
【场景化解决方案】搭建数据桥梁,Dslink打通泛微系统连接流
The embedded serial port interrupt can only receive one byte
NodeMCU(ESP8266) 接入阿里云物联网平台 踩坑之旅
SQL server中的数据类型
Redis高可用
约瑟夫问题的学习心得
jfinal加载配置文件原理
Difference: char* and char[]
Venture DAO 行业研报:宏观和经典案例分析、模式总结、未来建议
历史遗留问题
国产谷歌地球,地形分析秒杀同款地图软件
智慧图书馆的导航方案-定位导航导览-只用一个方案全部实现
运行flutter项目时遇到的问题
【场景化解决方案】钉钉财务审批同步金蝶云星空
无符号整数文法和浮点数文法