当前位置:网站首页>MySQL regularly deletes expired data.

MySQL regularly deletes expired data.

2022-06-11 04:47:00 Panbohhhhh

Mysql

First step : Detect whether the event trigger is turned on .

Input show variables like '%event_scheduler%';

If it is OFF, You need to enter the code to open

Turn on event_scheduler sql Instructions :
SET GLOBAL event_scheduler = ON;
SET @@global.event_scheduler = ON;
SET GLOBAL event_scheduler = 1;
SET @@global.event_scheduler = 1;

After the open , You can edit the event .

 


everyday In the morning am Delete regularly surface test   in 15 Days ago .
CREATE EVENT myevent
ON SCHEDULE EVERY 1 DAY STARTS '2009-03-25 02:00:00'
DO
delete from test where create_time <date_sub(curdate(),interval 15 day);

OK 了 .

 

原网站

版权声明
本文为[Panbohhhhh]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020545291199.html