tags:

views:

41

answers:

3

I want to ask about scheduling, is there any MySQL command for scheduling. For example, I want to insert a data into the DB. Can I write a sql statement to hold it for some time, or maybe I insert this data in some scheduled time, for example, tomorrow 8:00 a.m.

I know these can be done by programming, but I want to do it in SQL command, is it possible to do so? If not, any suggestions?

A: 

You may want to look at triggers.

Without more detail about exactly what you're trying to do this is a good place to start.

ennuikiller
+2  A: 

Scheduling background jobs is not part of the SQL command set. So it is down to each database vendor to provide their own extension. In Oracle it is a PL/SQL package, DBMS_SCHEDULER (or DBMS_JOB in older versions). In MYSQL it would appear to be the Event Scheduler, which use SQL syntax.

Edit

As Paul Dixon has pointed out the Event Scheduler is a relatively recent extension to MySQL (I'm not a MySQL expert, so forgive if this is not helpful to you).

APC
+1, I didn't know about that, added in MySQL 5.1
Paul Dixon
+1  A: 

MySQL 5.1.6+ has an Event Scheduler.

If you're using an earlier version, you could write a little script which executed the desired SQL, and schedule it with at,cron or similar.

Paul Dixon