How can I move an existing MySQL event to another database?


It can be done with the help of ALTER EVENT statement too. We need to use the combination of database name and event name along with the RENAME keyword. To illustrate it we are having the following example in which we are moving the event named ‘hello_renamed’ from ‘query’ database to ‘tutorial’ database −

Example

mysql> ALTER EVENT query.hello_renamed RENAME to tutorials.hello_renamed;
Query OK, 0 rows affected (0.00 sec)

To confirm that event has been moved to database ‘tutorials’ we can try to delete the event with an old name, MySQL will throw an error as follows −

mysql> DROP event hello_renamed;
ERROR 1539 (HY000): Unknown event 'hello_renamed'

Updated on: 22-Jun-2020

157 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements