IF NOT EXISTS  has the same meaning for CREATE EVENT  as for CREATE TABLE : If an event named event_name  already exists in the same schema, no action is taken, and no error results. (However, a warning is generated in such cases.) 

The ON SCHEDULE  clause determines when, how often, and for how long the event_body  defined for the event repeats. This clause takes one of two forms: 

• AT timestamp  is used for a one-time event. It specifies that the event executes one time only at the date and time given by timestamp , which must include both the date and time, or must be an expression that resolves to a datetime value. You may use a value of either the DATETIME  or TIMESTAMP  type for this purpose. If the date is in the past, a warning occurs, as shown here: 

mysql> SELECT NOW(); +---------------------+ | NOW() | +---------------------+ | 2006-02-10 23:59:01 | +---------------------+ 1 row in set (0.04 sec) mysql> CREATE EVENT e_totals -> ON SCHEDULE AT ’2006-02-10 23:59:00’ -> DO INSERT INTO test.totals VALUES (NOW()); Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> SHOW WARNINGS\G *************************** 1. row *************************** Level: Note Code: 1588 Message: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation. 

CREATE EVENT  statements which are themselves invalid—for whatever reason—fail with an error. 

You may use CURRENT_TIMESTAMP  to specify the current date and time. In such a case, the event acts as soon as it is created. 

To create an event which occurs at some point in the future relative to the current date and time—such as that expressed by the phrase “three weeks from now” —you can use the optional clause + INTERVAL interval . The interval  portion consists of two parts, a quantity and a unit of time, and follows the syntax rules described in Temporal Intervals, except that you cannot use any units keywords that involving microseconds when defining an event. With some interval types, complex time units may be used. For example, “two minutes and ten seconds”  can be expressed as + INTERVAL ’2:10’ MINUTE_SECOND . 

You can also combine intervals. For example, AT CURRENT_TIMESTAMP + INTERVAL 3 WEEK + INTERVAL 2 DAY  is equivalent to “three weeks and two days from now” . Each portion of such a clause must begin with + INTERVAL . 

•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 

