问题描述
我有一个mysql事件,每1天执行一次,然后进行一些活动。请查找相同的代码片段。 delimiter |
创建事件createTest
在日程表上每个1天
DO
BEGIN
- 做一些工作
END |
分隔符
当我创建此事件时,它在同一天执行相同的时间。第二天执行(最后执行+ 24小时)方案。
是否可以在事件中设置开始时间?我想每天0小时执行这个事件?
是的,你可以做到。为此目的使用STARTS选项。
CREATE EVENT event1
ON SCHEDULE EVERY'1'DAY
STARTS '2012-10-03 00:00:00'
DO
BEGIN
- 做某事
END
请注意,该事件启动日期时间必须在将来。
对于@spt -
CREATE EVENT event1
ON SCHEDULE EVERY'1'YEAR
STARTS' 2016-04-01 00:00:00'
DO
BEGIN
END
另外,如果很难创建和设置事件对象,可以在(免费快速版允许它)。
I have one mysql event which will execute every 1 day and do some activity. Please find code snippets for the same.
delimiter |
CREATE EVENT createTest
ON SCHEDULE EVERY 1 DAY
DO
BEGIN
-- Do some work
END |
delimiter ;
when i created this event it executes same time for the same day. For next day it executes (last execution + 24 Hour) scenario.
is it possible to set start time in events? I want to executes this events on every day 0 hour?
Yes, you can do it. Use STARTS option for this purpose.
CREATE EVENT event1
ON SCHEDULE EVERY '1' DAY
STARTS '2012-10-03 00:00:00'
DO
BEGIN
-- do something
END
Note, that event start datetime must be in a future.
For @spt -
CREATE EVENT event1
ON SCHEDULE EVERY '1' YEAR
STARTS '2016-04-01 00:00:00'
DO
BEGIN
END
Also, if it is hard to create and setup event object, you can use GUI event object editor in dbForge Studio for MySQL (free Express edition allows it).
这篇关于Mysql事件执行开始时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!