mysql:无法识别的语句类型。 (靠近 SCHEDULE)尝试创建事件日程时

标签 mysql

我正在尝试创建事件计划,但 phpmyadmin 在左侧显示错误“无法识别的语句类型”。 (接近时间表)'。 MySql版本是10.1.8。我真的不明白这段代码或 MySql/phpmyadmin 或任何其他配置有什么问题。

    DELIMITER $$
    CREATE 
        EVENT `archive_blogs` 
        ON SCHEDULE
        EVERY 1 DAY
        STARTS '20:00:00' ON COMPLETION PRESERVE ENABLE 
        DO BEGIN
            .....
        END */$$
    DELIMITER ;

捕捉错误:无法识别的语句类型。 (接近时间表)

enter image description here

最佳答案

MySql version is 10.1.8

你确定是MySQL吗?可能是 MariaDB? 您在哪里收到此错误 - 脚本、phpMyAdmin? 您是否尝试从控制台执行它?

至于

STARTS '20:00:00'

尝试以下安装

STARTS CONCAT(DATE(NOW()+INTERVAL 1 DAY ), ' 20:00:00')

来自 MySQL 文档:

To repeat actions at a regular interval, use an EVERY clause. The EVERY keyword is followed by an interval as described in the previous discussion of the AT keyword. (+ INTERVAL is not used with EVERY.) For example, EVERY 6 WEEK means “every six weeks”.

Although + INTERVAL clauses are not permitted in an EVERY clause, you can use the same complex time units permitted in a + INTERVAL.

An EVERY clause may contain an optional STARTS clause. STARTS is followed by a timestamp value that indicates when the action should begin repeating, and may also use + INTERVAL interval to specify an amount of time “from now”. For example, EVERY 3 MONTH STARTS CURRENT_TIMESTAMP + INTERVAL 1 WEEK means “every three months, beginning one week from now”. Similarly, you can express “every two weeks, beginning six hours and fifteen minutes from now” as EVERY 2 WEEK STARTS CURRENT_TIMESTAMP + INTERVAL '6:15' HOUR_MINUTE. Not specifying STARTS is the same as using STARTS CURRENT_TIMESTAMP—that is, the action specified for the event begins repeating immediately upon creation of the event.

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.

关于mysql:无法识别的语句类型。 (靠近 SCHEDULE)尝试创建事件日程时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33866093/

相关文章:

python - 使用 Python 2.7 从 Excel 导入 MySQL 表

mysql - 按最常见的值对 mysql 结果进行排序

php - 变量 $_GET 变量

php - 使用 php 列出 mysql 数据库

MySQL5.7组复制问题?

php - mysql 查询没有收到任何结果

mysql - 选择前 n 个字符相等的行 (MySQL)

mysql - 在列中重复外键

php - PHP 表单中电子邮件的域特定验证

php - 插入获取数组数据到新数据库