1.1 需求和大致思路
要求把mysql的数据定时同步到另一个schema下,并清理数据,不同的表有不同的策略,如sys_operation_log表每个月调度一次备份数据并清理半年前的数据:
采用springboot schedule定时任务动态(从数据库读取)读取执行
create table if not exists ddh_sbztjk_prod.dump_del
(
id int not null
primary key,
originTable varchar(100) not null,
desTable varchar(100) not null,
primaryCol varchar(100) not null,
delWhere varchar(100) not null,
cron varchar(100) not null
);

<select id="getMax" resultType="java.lang.Long" statementType="STATEMENT">
select max(${col}) from ${des}.${desTable}
</select>
<insert id="insertToAnotherTable" statementType="STATEMENT"><
SpringBoot+MyBatis动态SQL实现数据同步与清理

本文介绍了如何使用SpringBoot Schedule结合MyBatis动态SQL实现数据库表的数据同步与清理策略。通过配置动态表名,利用#{}
最低0.47元/天 解锁文章
430

被折叠的 条评论
为什么被折叠?



