当前位置:网站首页>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表)

边栏推荐
猜你喜欢
随机推荐
Anaconda4.8.3介绍、安装及使用教程安装(win10)并修改Jupyter默认工作目录
多维度LSTM(长短期记忆)神经网络预测未来存款余额走势
使用图新地球无法加载谷歌地球的完美解决方法(附软件下载)
没有对象的可以进来看看, 这里有对象介绍
第1讲 Verilog基础知识
加密技术和电子竞技如何促进彼此的发展
MySQL创建索引的技巧
canal工作原理及简单案例演示
NodeMCU(ESP8266) 接入阿里云物联网平台 踩坑之旅
[V&N2020 公开赛]内存取证
BUUCTF MISC brush notes (2)
关于指针、地址的大小的问题(以及malloc的用法)
sizeof 结构体问题
centos7 mysql异常ERROR 2002 (HY000)分析解决
【环境搭建】onnx-tensorrt
MySQL Leak Detection and Filling (3) Calculated Fields
When and How to use MALLOC
数理逻辑MOOC+知识点总结(未完无待续)
常用SQL server语句
[V&N2020 Open] Memory Forensics








