如何在 mysql 中创建作业或事件 [英] How can I create a Job or event in mysql

查看:72
本文介绍了如何在 mysql 中创建作业或事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一天结束时运行的 mysql 中创建一个作业,在该作业中我想更新表中的一些列值.假设我有 2 个表,其中有一个名为 Status 的列,它是 Pending 或 Accepted.为此,我想创建一个工作,我想在其中搜索两个表并将 Pending 状态设置为 Accepted.

I would like to create a job in mysql which runs on the end of the day, where in that job I would like to update some of the column values in my tables. Assume I am having 2 tables where I am having a column named Status which is either Pending or Accepted. For this I would like to create a Job where I would like to search the two tables and set Pending status to Accepted.

有没有可能

推荐答案

使用 MySQL 的 事件调度程序:

Use MySQL's Event Scheduler:

DELIMITER ;;

CREATE EVENT foo ON SCHEDULE EVERY DAY STARTS '2012-10-05 00:00:00' DO BEGIN
  UPDATE table1 SET Status = 'Accepted' WHERE Status = 'Pending';
  UPDATE table2 SET Status = 'Accepted' WHERE Status = 'Pending';
END;;

DELIMITER ;

这篇关于如何在 mysql 中创建作业或事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆