Not the answer you need?
Register and ask your own question!

How to delete multiple events in single query using mysql 8.0?

deep.pateldeep.patel EntrantCurrent User Role Beginner
I am using mysql 8.0 and I need to delete multiple events in single query. Please help me for delete multiple events.

Comments

  • lorraine.pocklingtonlorraine.pocklington Percona Community Manager Legacy User Role Patron
    You either have to drop them singularly i.e. DROP EVENT xxx as per this manual page https://dev.mysql.com/doc/refman/8.0/en/drop-event.html

    OR you can generate the drop script by using something like this (add a filter to the select if you need to be more specific) :
    mysql -Dinformation_schema -BNse "select event_schema, event_name from events" | while read db evnt; do mysql -D $db -Bse "drop event if exists $evnt"; done
    

    Please note that according to this page, https://dev.mysql.com/doc/refman/8.0/en/events-privileges.html you can delete multiple events with a single query, however we believe this to be a documentation error and do not recommend you do it this way. Firstly, it requires high level privileges, which may not be appropriate, and it also looks like you need to be running in debug mode which is not a great idea for production. We don't recommend you follow that approach.

    Hope this helps?
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.