mysql - 更改事件并将结束设置为空

标签 mysql sql

嘿,我创建了一个在特定时间戳结束的事件,并希望将其更改为无限运行。

我试过运行:

ALTER EVENT event_name 
ON SCHEDULE EVERY '5' MINUTE 
STARTS '2013-10-21 14:49' ENDS NULL 
ON COMPLETION PRESERVE ENABLE    DO [code];

但我收到错误代码:1543。ENDS 无效或在 STARTS 之前

如何做到这一点?我知道我可以在遥远的 future 设置一个看起来无穷大的日期,但我希望将 ENDS 设置为空。

如果我简单地排除了 ENDS 参数,它就会卡在旧的结束日期上,你可以看到:select * from information_schema.events 但事件确实继续运行,就好像 ENDS 为空一样。这主要是我需要实现的目标。

最佳答案

我相信 ENDS 参数是可选的,否则您可以指定 future 的日期。 ENDS 后面必须跟一个时间戳。

An EVERY clause may contain an optional ENDS clause. The ENDS keyword is followed by a timestamp value that tells MySQL when the event should stop repeating. You may also use + INTERVAL interval with ENDS; for instance, EVERY 12 HOUR STARTS CURRENT_TIMESTAMP + INTERVAL 30 MINUTE ENDS CURRENT_TIMESTAMP + INTERVAL 4 WEEK is equivalent to “every twelve hours, beginning thirty minutes from now, and ending four weeks from now”. Not using ENDS means that the event continues executing indefinitely.

ENDS supports the same syntax for complex time units as STARTS does.

You may use STARTS, ENDS, both, or neither in an EVERY clause.

http://dev.mysql.com/doc/refman/5.1/en/create-event.html

您唯一的选择(和解决方法)是重新创建事件 ( http://bugs.mysql.com/bug.php?id=39173 )。

关于mysql - 更改事件并将结束设置为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19493710/

相关文章:

mysql报告每日查询按类型过滤,包括丢失的分组行

MySQL 不返回空列连接值

C# - 大型集合存储

sql - 比较日期而不考虑时间(MSSQL)

mysql - 删除重复行,没有唯一键 - 关系表

android - 无法将数据从 Android 更新到服务器

php - MySQL 表锁定(读)

java - 将表保存在 Docker 容器中

c# - .NET 有免费的 SQL 格式化库吗?

SQL : First condition in OR statement in JOIN is always executed first?