example
ON SCHEDULE EVERY 1 HOUR
STARTS CURRENT_TIMESTAMP + INTERVAL 1 MONTH
ENDS CURRENT_TIMESTAMP + INTERVAL 1 MONTH + INTERVAL 1 WEEK
DO some_task;

Intervals consist of a quantity and a time unit. The time units are the same
used for other staments and time functions, except that you can't use
microseconds for events. For simple time units, like HOUR or MINUTE, the
quantity is an integer number, for example '10 MINUTE'. For composite time
units, like HOUR_MINUTE or HOUR_SECOND, the quantity must be a string with all
involved simple values and their separators, for example '2:30' or '2:30:30'.

ON COMPLETION [NOT] PRESERVE
----------------------------

The ON COMPLETION clause can be used to specify if the event must be deleted
after its last execution (that is, after its AT or ENDS timestamp is past). By
default, events are dropped when they are expired. To explicitly state that
this is the desired behaviour, you can use ON COMPLETION NOT PRESERVE.
Instead, if you want the event to be preserved, you can use ON COMPLETION
PRESERVE.

In you specify ON COMPLETION NOT PRESERVE, and you specify a timestamp in the
past for AT or ENDS clause, the event will be immediatly dropped. In such
cases, you will get a Note 1558: "Event execution time is in the past and ON
COMPLETION NOT PRESERVE is set. The event was dropped immediately after
creation".

ENABLE/DISABLE/DISABLE ON SLAVE
-------------------------------

Events are ENABLEd by default. If you want to stop MariaDB from executing an
event, you may specify DISABLE. When it is ready to be activated, you may
enable it using ALTER EVENT. Another option is DISABLE ON SLAVE, which
indicates that an event was created on a master and has been replicated to the
slave, which is prevented from executing the event. If DISABLE ON SLAVE is
specifically set, the event will be disabled everywhere. It will not be
executed on the mater or the slaves.

COMMENT
-------

The COMMENT clause may be used to set a comment for the event. Maximum length
for comments is 64 characters. The comment is a string, so it must be quoted.
To see events comments, you can query the INFORMATION_SCHEMA.EVENTS table (the
column is named EVENT_COMMENT).

Examples
--------

Minimal CREATE EVENT statement:

CREATE EVENT myevent
  ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
  DO
   UPDATE myschema.mytable SET mycol = mycol + 1;

An event that will be triggered tomorrow at a certain time:

CREATE EVENT example
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY + INTERVAL 3 HOUR
DO something;

Next month a recurring event will be triggered hourly for a week:

CREATE EVENT example
ON SCHEDULE EVERY 1 HOUR
STARTS CURRENT_TIMESTAMP + INTERVAL 1 MONTH
ENDS CURRENT_TIMESTAMP + INTERVAL 1 MONTH + INTERVAL 1 WEEK
DO some_task;

OR REPLACE and IF NOT EXISTS:

CREATE EVENT myevent
  ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
  DO
   UPDATE myschema.mytable SET mycol = mycol + 1;
ERROR 1537 (HY000): Event 'myevent' already exists

CREATE OR REPLACE EVENT myevent
  ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
  DO
   UPDATE myschema.mytable SET mycol = mycol + 1;;
Query OK, 0 rows affected (0.00 sec)

CREATE EVENT IF NOT EXISTS myevent
  ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
  DO
   UPDATE myschema.mytable SET mycol = mycol + 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

SHOW WARNINGS;
+-------+------+--------------------------------+
| Level | Code | Message                        |
+-------+------+--------------------------------+
| Note  | 1537 | Event 'myevent' already exists |
+-------+------+--------------------------------+

URL: https://mariadb.com/kb/en/create-event/https://mariadb.com/kb/en/create-event/