返回顶部

收藏

mysql 任务调度实现

更多

今天有个业务需求,每天要重置流水号.想起oracle有job 于是联想到Mysql应该有类似的.发现mysql

通过EVENT 来实现

语法如下

    CREATE EVENT [IF NOT EXISTS] event_name  

        ON SCHEDULE schedule  

        [ON COMPLETION [NOT] PRESERVE]  

        [ENABLE | DISABLE]  

        [COMMENT 'comment']  

        DO sql_statement;  

    schedule:  

        AT TIMESTAMP [+ INTERVAL INTERVAL]  

    | EVERY INTERVAL [STARTS TIMESTAMP] [ENDS TIMESTAMP]  

    INTERVAL:  

        quantity {YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |  

                  WEEK | SECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE |  

                  DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND}  

简单使用如下sql None

标签:sql

收藏

0人收藏

支持

0

反对

0

发表评论