13

What is a "MySQL event"? What is its purpose? How is it different from a "job scheduler"?

Many posts on SO, and the MySQL documentation, describe how to implement MySQL events, but I am just interested in their purpose.

Pops
  • 30,199
  • 37
  • 136
  • 151
Don P
  • 60,113
  • 114
  • 300
  • 432

1 Answers1

18

MySQL events offer an alternative to scheduled tasks and cron jobs.

Events can be used to create backups, delete stale records, aggregate data for reports, and so on. Unlike standard triggers which execute given a certain condition, an event is an object that is triggered by the passage of time and is sometimes referred to as a temporal trigger.

Refer below link explained everything here :

http://phpmaster.com/working-with-mysql-events/

  • 1
    Thanks Teez - great answer :). One additional question, it sounds like MySQL events only execute SQL commands. Do you know of a good job scheduler if I want to be executing a PHP script? – Don P Jan 29 '12 at 21:41
  • 3
    Thanks for the PHPmaster link, very helpful. – Don P Jan 29 '12 at 21:57
  • Suppose that I allow users to edit a thing (which has editable=true in the database) for 7 days. Would it be appropriate usage to set a MySQL event to set editable=false after 7 days? Or it should only be used for batch processing etc? – hytromo Jun 09 '15 at 21:46