Home  >  Article  >  Database  >  A brief introduction to event planning tasks in MySQL

A brief introduction to event planning tasks in MySQL

黄舟
黄舟Original
2017-05-28 09:40:031076browse

The following editor will bring you a brief discussion of MySQL event planning tasks. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.

1. Check whether the event is turned on

##show variables like '%sche%';

set global event_scheduler =1;

2.

--Set the time zone and set the planned event scheduler to turn on, or event_scheduler = ON

set time_zone = '+8:00';
set GLOBAL event_scheduler = 1;

--Set the database base database that the event uses or belongs to

use test;

-- If there is a task plan with this name, delete it first

drop event if exist test_update;

-- Set the separator to '$$', the default statement separator of mysql is ';' , so that the subsequent code from create to end will be regarded as a statement to execute

DELIMITER $$

-- Create a scheduled task and set the first execution time to '2012-11-15 10:00:00', and executed once a day

-- on schedule every 30 second

-- on schedule every day starts timestamp '2012-11-15 10:00:00'

create event test_update

on schedule every day starts timestamp '2012-11-15 10:00:00'
do

-- What to do when starting this scheduled task

begin

-----------------------------------

-- do something write What your planned task will do
-----------------------------------

-- End scheduled task

end $$

-- Set the statement delimiter back to ';'

DELIMITER ;

The above is the detailed content of A brief introduction to event planning tasks in MySQL. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn