MySQL 5.1 创建事件(CREATE EVENT)的语法

  • Post author:
  • Post category:mysql



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


}



[ON COMPLETION [NOT] PRESERVE]可以设置这个事件是执行一次还是持久执行,默认为NOT PRESERVE。


[ENABLE | DISABLE]可是设置该事件创建后状态是否开启或关闭,默认为ENABLE。

[COMMENT ‘comment’]可以给该事件加上注释。