In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
How to implement timing execution in mysql? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
After version 5.1, MYSQL supports timing execution (event), which is similar to linux's crontab.
First take a look at your MSYQL version and query the SQL statement for version information:
Select VERSION ()
After confirming the version support, check whether event is enabled:
Show variables like'% sche%'
If it is not open, how can it be opened?
Show VARIABLES LIKE'% sche%'
Set global event_scheduler = 1
Show VARIABLES LIKE'% sche%'
In general, there are two kinds of timing execution:
1. From a specific point in time, it will be executed at regular intervals.
From now on, it will be executed every 30 seconds
Create event if not exists e_test
On schedule every 30 second starts now ()
On completion preserve
Do
INSERT into sdb_yoyi (yoyiscid,orderid) VALUES (2pr 3)
2. Start from a specific point in time and execute at a certain point in the day.
Executed at 1: 00 a. M. on the first of every month
Create event if not exists e_test2
On schedule every 1 month starts DATE_ADD (DATE_ADD (DATE_SUB (CURDATE (), INTERVAL DAY (CURDATE ())-1 DAY), INTERVAL 1 MONTH), INTERVAL 1 HOUR)
On completion preserve
Do
INSERT into sdb_yoyi (yoyiscid,orderid) VALUES (2pr 3)
You can also turn off the event task:
Alter event e_test ON
COMPLETION PRESERVE DISABLE
Open event tasks that have been closed:
Alter event e_test ON
COMPLETION PRESERVE ENABLE
This is the answer to the question about how to implement timing execution in mysql. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.