In MySQL we can use the CREATE EVENT
statement to create scheduled events. As with many CREATE ...
statements, we have the option of using the IF NOT EXISTS
clause to specify that the object should only be created if it doesn’t already exist.
Of course, we wouldn’t normally be trying to create an event if we know that it already exists. But there may be times where we’re not sure, and we want our code to handle this scenario without throwing an error if an event with the same name already exists. This is common when creating scripts that are designed to be run across multiple environments. That’s where the IF NOT EXISTS
clause can come in handy.