批量插入大量数据

1.设置数据库&rewriteBatchedStatements=true 会大幅度提升效率

2.批量插入

<insert id="insertBatch" parameterType="java.util.List">
insert into m_user_group_detail (id, plan_id, user_info,
user_group_filter_time, send_kafka, to_channel,
to_channel_success, to_channel_seq, is_reach,
create_time, update_time, t_del
)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.planId,jdbcType=VARCHAR}, #{item.userInfo,jdbcType=VARCHAR},
#{item.userGroupFilterTime,jdbcType=VARCHAR}, #{item.sendKafka,jdbcType=VARCHAR}, #{item.toChannel,jdbcType=VARCHAR},
#{item.toChannelSuccess,jdbcType=VARCHAR}, #{item.toChannelSeq,jdbcType=VARCHAR}, #{item.isReach,jdbcType=VARCHAR},
#{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.tDel,jdbcType=VARCHAR}
)
</foreach>
</insert>
上一篇:MyBatis+Oracle+Sequence


下一篇:【SQL】多列组合选择