mysql定时任务按天建表并跨库同步数据
Posted hkronline-syncnavigator
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql定时任务按天建表并跨库同步数据相关的知识,希望对你有一定的参考价值。
创建定时任务完成:创建ASR识别记录表,每天自动从小云AI对话详情表同步数据。
*/
DROP PROCEDURE IF EXISTS `create_o_asr_record_call`;
DELIMITER ;;
CREATE PROCEDURE `create_o_asr_record_call`(IN `dayInt` bigint,out result int)
COMMENT ‘ASR识别结果表--按日--建表‘
BEGIN
set @sql_tmp3 = CONCAT(‘create table o_asr_record_‘,dayInt,‘ like o_asr_record_0 ‘);
PREPARE stmt3 FROM @sql_tmp3;
EXECUTE stmt3;
DEALLOCATE PREPARE stmt3;
set @engine_tab = CONCAT(‘uc_ipcc_cloud_ai_stat.‘,‘tb_ucpaas_engine_‘,DATE_FORMAT(date_sub(curdate(),interval 1 day),‘%Y%m%d‘));
set @sql_tmp_insert = CONCAT(‘INSERT INTO ‘, CONCAT(‘o_asr_record_‘,dayInt),‘(`callid`,`derial_number`,`content`,`record_url`)‘,‘ select callid,derial_number,text,record_url from ‘, @engine_tab);
PREPARE stmt_insert FROM @sql_tmp_insert;
EXECUTE stmt_insert;
DEALLOCATE PREPARE stmt_insert;
set result = 1;
END
;;
DELIMITER ;
-- 创建定时任务
DELIMITER //
DROP EVENT IF EXISTS event_sync_asr_record//
CREATE EVENT event_sync_asr_record
on schedule EVERY 1 DAY STARTS date_add(curdate(),interval 30 HOUR_MINUTE)
do
BEGIN
call create_o_asr_record_call (DATE_FORMAT(now(),‘%Y%m%d‘),@1);
END//
DELIMITER ;
create_o_asr_record_call
create_o_asr_record_call
---------------------
作者:Jeff.Sheng
来源:CSDN
原文:https://blog.csdn.net/shengqianfeng/article/details/80270695
版权声明:本文为博主原创文章,转载请附上博文链接!
以上是关于mysql定时任务按天建表并跨库同步数据的主要内容,如果未能解决你的问题,请参考以下文章