当前位置:网站首页>MySQL regularly calls preset functions to complete data update
MySQL regularly calls preset functions to complete data update
2022-07-29 04:52:00 【Pursue flying】
MySQL Call preset functions regularly to complete data update
One 、 Software preparation
- Navicat
- MySQL5.7
Two 、 Turn on MySQL Event plan
Inquire about MySQL Whether the event plan is started .
show VARIABLES LIKE 'event%';
If not, open .
SET GLOBAL event_scheduler = 1;
3、 ... and 、 establish MySQL function
Functions and procedures are very similar , So create the function directly ,Navicat Software also puts processes and functions together Function menu bar
.
3.1 Write SQL sentence
Write the required business SQL sentence , And test , For example, move the data of a terminal backward as a whole 3 Months .
update table set date = DATE_ADD(date,INTERVAL 3 month) WHERE number = '110'
3.2 Create a function
BEGIN
#Routine body goes here...
update table set date = DATE_ADD(date,INTERVAL 3 month) WHERE number = '110';
RETURN 0;
END;
Click save , Name the function updateData
, The parameter is set to null , Complete function creation .
In the function menu bar, you can see the function just saved .
3.3 Create an event
call updateData
The status is set to ENABLE.
ON COMPLETETION Set to PERSERVE
, This parameter indicates " When this event will not happen again ", That is, when a single planned task is executed or when a repetitive planned task is executed ENDS Stage . and PRESERVE The function of is to ensure that the event will not be killed after execution .
alike , Name the event , The newly saved event will appear in the event menu bar .
Then set the call cycle of the event .
Four 、 Query the event plan
SELECT * from mysql.`event`;
The following event plan details appear ,
边栏推荐
- 2022杭电多校联赛第四场 题解
- GCC Basics
- The most complete NLP Chinese and English stop words list in the whole station (including punctuation marks, which can be copied directly)
- UE 在场景或UMG中播放视频
- EMI interference troubleshooting with near-field probe and current probe
- Detailed comparison of break and continue functions
- Un7.28: common commands of redis client.
- IOS interview preparation - other articles
- img 响应式图片的实现(含srcset属性、sizes属性的使用方法,设备像素比详解)
- 学术 | [LaTex]超详细Texlive2022+Tex Studio下载安装配置
猜你喜欢
安装spinning up教程里与mujoco对应的gym,报错mjpro150
【无标题】
删除word文档中的空白页
UE 在场景或UMG中播放视频
Deep analysis of data storage in memory (Advanced C language)
Flink+Iceberg环境搭建及生产问题处理
Learn matlab to draw geographical map, line scatter bubble density map
Correct user dragging method
Pycharm reports an error when connecting to the virtual machine database
五个关联分析,领略数据分析师一大重要必会处理技能
随机推荐
Conv2d of torch
What are the core features of the digital transformation of state-owned construction enterprises?
Climbing the pit of traffic flow prediction (II): the simplest LSTM predicts traffic flow using tensorflow2
1 句代码,搞定 ASP.NET Core 绑定多个源到同一个类
让你的正则表达式可读性提高一百倍
[c language] PTA 7-51 sum the first n terms of odd part sequence
Flink+Iceberg环境搭建及生产问题处理
[express connection to MySQL database]
Classes and objects (II)
C语言实现三子棋
STL source code analysis (Hou Jie) notes -- Classification and testing of stl containers
excel怎么设置行高和列宽?excel设置行高和列宽的方法
un7.28:redis客户端常用命令。
Numpy basic learning
如何安装office2010安装包?office2010安装包安装到电脑上的方法
iOS面试准备 - ios篇
Basic grammar of C language
[c language] PTA 7-48 find the number of combinations
[C] PTA 6-8 finding the height of binary tree
ssm整合增删改查