Home > Database > Mysql Tutorial > A brief analysis of MySQL event scheduled tasks

A brief analysis of MySQL event scheduled tasks

小云云
Release: 2018-01-17 10:19:12
Original
1215 people have browsed it

This article mainly brings 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 to take a look, I hope it can help everyone.

1. Check whether the event is enabled

show variables like '%sche%';
set global event_scheduler =1;

2.

--Set the time zone and set the planned event scheduler to turn on, you can also 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 the name originally exists The task plan will first delete
drop event if exist test_update;

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

-- Create a scheduled task, set the first execution time to '2012-11-15 10:00:00', and Execute 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 planned task
end $$

-- Set the statement delimiter back to ';'
DELIMITER ;

Related recommendations:

##JS Detailed explanation of the difference between this and event

Detailed introduction about event

Detailed explanation of the difference between this and event in js

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template