是否可以制作一个每晚晚上 11 点运行的存储过程,检查表中是否有最近六个月修改的记录,如果最近六个月修改了某些记录,我必须将其从表中删除.这必须在不使用任何外部语言的情况下自动运行.
Is it possible to make a stored procedure that run every night 11 pm , check in table if any record is modified for last six month, If some record is modified for last six month I have to delete it from table. This has to run automatically without use of any external language.
CREATE EVENT IF NOT EXISTS `my_old_data_cleaner_event`
ON SCHEDULE EVERY 23 DAY_HOUR
COMMENT 'Clean up Service Start at 11:00PM daily!'
DO DELETE FROM my_table WHERE created_date < (NOW() - INTERVAL 1 MONTH);
OR 用于存储过程.
CREATE EVENT IF NOT EXISTS `my_old_data_cleaner_event`
ON SCHEDULE EVERY 23 DAY_HOUR
DO CALL my_sp_cleanup_old_data();
这篇关于在 mysql 中自动运行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!