【问题标题】:mysql: unrecognized statement type. (near SCHEDULE) when try to create event schedulemysql:无法识别的语句类型。 (在 SCHEDULE 附近)尝试创建活动时间表时
【发布时间】:2015-11-23 07:59:45
【问题描述】:

我正在尝试创建活动时间表,但 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 ;

快照错误: 无法识别的语句类型。 (靠近时间表)

【问题讨论】:

  • 只是在黑暗中拍摄,但请尝试在活动名称周围不加引号。
  • 仍然显示错误@darwinvonCorax
  • @MirAbzalAli,请通过DateTime 进行检查。
  • 您是否尝试过运行查询?因为在旧的phpmyadmin 中有bugsql parser 中,所以它显示错误但在某些情况下它仍然运行。

标签: mysql


【解决方案1】:

MySql 版本为 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 版本,MariaDB 还有其他语法吗? phpmyadmin 中仍然出现错误。
  • 在 STARTS 表达式中添加 DATE:STARTS CONCAT(DATE(NOW()+INTERVAL 1 DAY ), '20:00:00') 或 STARTS '2015-11-23 20:00: 00'
  • 当我在控制台尝试它时'不被识别为内部或外部命令可运行程序或批处理文件'。
  • 这个错误听起来像是与操作系统相关的错误,但不是最初的问题。检查此链接:helpdeskgeek.com/how-to/…
【解决方案2】:

试试这个,它似乎也想要约会。

DELIMITER $$
CREATE EVENT `archive_blogs` 
    ON SCHEDULE
    EVERY 1 DAY
    STARTS '2015-11-23 20:00:00' 
    ON COMPLETION PRESERVE ENABLE 
    DO 
        select 8 as 'eight';
    $$
DELIMITER ;

它通过我的系统。

Create Event 手册页。

【讨论】:

  • 得到同样的错误,这里'ON'和';'附近有两个错误
  • show variables where variable_name in ('innodb_version','version_comment')
  • innodb_version - 5.6.26-74.0 version_comment -mariadb.org 二进制分发
  • 显示错误,查询成功执行并创建了我在 information_schema 中看到的事件。但不确定它是否会起作用。很大的帮助。
猜你喜欢
  • 2022-01-21
  • 1970-01-01
  • 1970-01-01
  • 2018-10-06
  • 1970-01-01
  • 2019-01-16
  • 2021-11-24
  • 2019-09-07
  • 2020-08-30
相关资源
最近更新 更多