如何在mysql中设置计时器 [英] How to set a timer in mysql

查看:48
本文介绍了如何在mysql中设置计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设当前日期是 20141110 10:00pm ,我想让 mysql 更新一个字段,然后将几个字段转储到一个文件中,而日期是 20141201 10:00pm

Suppose the current date is 20141110 10:00pm , I would like to let mysql to update a field and then dump few fields into a file while the date is 20141201 10:00pm

如何实现?

我所知道的是使用事件,但这似乎是在某些间隔时间下使用的.就像每隔几个小时/天/周让事件发生.

What I know is to use event, but this seems to be used under some interval time. like every few hours/days/weeks to make the event happen.

推荐答案

您可以为活动的时间表声明一个固定的时间点.间隔部分是可选的.

You can declare a fixed point in time for the event's schedule. The interval part is optional.

这是出现在手册页上的示例 http://dev.mysql.com/doc/refman/5.6/en/create-event.html

Here's an example that appears on manual page http://dev.mysql.com/doc/refman/5.6/en/create-event.html

mysql> CREATE EVENT e_totals
    ->     ON SCHEDULE AT '2006-02-10 23:59:00'
    ->     DO INSERT INTO test.totals VALUES (NOW());

另请注意,您不必使用存储过程.

Note also that you do not have to use a stored procedure.

这篇关于如何在mysql中设置计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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