You can use this statement to modify an existing event.
Syntax
ALTER
[DEFINER = user]
EVENT event_name
[ON SCHEDULE schedule]
[ON COMPLETION [NOT] PRESERVE]
[RENAME TO new_event_name]
[ENABLE | DISABLE | DISABLE ON SLAVE]
[COMMENT 'string']
[DO event_body]
Parameters
| Parameter | Description |
|---|---|
| event_name | The name of the event to be modified. |
| DEFINER | Optional. The user that modifies the event. You cannot define the user. The default value is the current user. |
| ON SCHEDULE schedule | Modifies the schedule of the event. The value is in the format of "a timestamp + INTERVAL", for example, "2020-12-01 00:00:00 + INTERVAL 1 DAY". The interval value must be an integer and the time unit can be YEAR, MONTH, DAY, HOUR, MINUTE, or SECOND. |
| ON COMPLETION [NOT] PRESERVE | Specifies whether to retain the event after it is executed. The default value is NOT PRESERVE, which specifies to automatically delete the event after it is executed. |
| ENABLE, DISABLE, DISABLE ON SLAVE | The status of the event. The default value is ENABLE, which specifies to immediately enable an event after it is created. DISABLE specifies to disable an event after it is created. The event will not be automatically executed until it is manually enabled. DISABLE ON SLAVE specifies not to execute the event on the server. This value is used only in an environment that involves replication. |
| COMMENT 'string' | Optional. The comment on the event. |
| DO event_body | A new SQL statement to replace the original operation of the event. You can specify only one SQL statement here. BEGIN ... END supports multiple SQL statements. |
Examples
obclient> ALTER EVENT myevent
ON SCHEDULE
AT '2024-07-02 00:00:00' + INTERVAL 1 DAY
DO
TRUNCATE TABLE myschema.mytable;
Note
You can execute the ALTER EVENT statement only on an existing event.