mg4377娱乐娱城官网_mg4377娱乐手机版_www.mg4377.com

当前位置: mg4377娱乐娱城官网 > mg > 正文

mysql按时义务与存款和储蓄进度实例,让叁个囤积

时间:2019-07-07 00:46来源:mg
1、在mysql 中确立三个数据库 test1 /**查看event是否开启 : SHOW VARIABLES LIKE '%event_sche%';将事件计划开启 : SET GLOBAL event_scheduler = 1; 将事件计划关闭 : SET GLOBAL event_scheduler = 0; 关闭事件任务 :

1、在mysql 中确立三个数据库 test1

/**
查看event是否开启 : SHOW VARIABLES LIKE '%event_sche%';
将事件计划开启 : SET GLOBAL event_scheduler = 1; 
将事件计划关闭 : SET GLOBAL event_scheduler = 0; 
关闭事件任务 : ALTER EVENT eventName ON COMPLETION PRESERVE DISABLE; 
开启事件任务 : ALTER EVENT eventName ON COMPLETION PRESERVE ENABLE; 
查看事件任务 : SHOW EVENTS ;

delimiter //   设定语句终结符为 //,因存储过程语句用;结束 
**/

DROP TABLE IF EXISTS test;                
CREATE TABLE test (
  id           bigint(11) unsigned NOT NULL AUTO_INCREMENT,
  name         varchar(100) NOT NULL DEFAULT '',
  create_time  datetime,
  PRIMARY KEY (ID)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;


DELIMITER //
DROP PROCEDURE IF EXISTS p_test//
CREATE PROCEDURE p_test()  
BEGIN  
INSERT INTO test(name, create_time) values('testName', now());
END//

DROP EVENT IF EXISTS e_test//
CREATE EVENT e_test  
ON SCHEDULE EVERY 10 second STARTS TIMESTAMP '2014-04-09 01:00:00' 
ON COMPLETION PRESERVE  
DO 
BEGIN   
CALL p_test();
END//

mysql按时义务与存款和储蓄进度实例,让叁个囤积进程定期作业的代码。语句:create database test1

如上事件e_test表示每10秒试行贰遍p_test()

2、创建表examinfo

: SHOW VARIABLES LIKE '%event_sche%';将事件布署开启 : SET GLOBAL event_scheduler = 1; 将事件布署关闭 : SET GLOBAL event_scheduler = 0; 关闭...

create table examinfo(
id int auto_increment not null,
endtime datetime,
primary key(id)
);

3 插入数据:

insert into examinfo values('1','2011-4-23 23:26:50');

4 创立存款和储蓄进度test

CREATE PROCEDURE test ()
BEGIN
update examinfo SET endtime = now() WHERE id = 1;
END;

编辑:mg 本文来源:mysql按时义务与存款和储蓄进度实例,让叁个囤积

关键词: