V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
mortonnex
V2EX  ›  问与答

mysql 批量更新的问题

  •  
  •   mortonnex · Oct 25, 2018 · 1113 views
    This topic created in 2754 days ago, the information mentioned may be changed or developed.
    <update id="updateList" parameterType="java.util.List">  
            <foreach close=";" collection="list" index="index" item="record" open="" separator=";">  
                update A set value=#{record.value,jdbcType=VARCHAR}  
                where detail_id=#{record.detailId,jdbcType=BIGINT} AND org_id=#{record.orgId,jdbcType=BIGINT} AND l_date=#{record.lDate,jdbcType=INTEGER} AND location=#{record.location,jdbcType=VARCHAR}
            </foreach>
    </update> 
    

    类似这种,如果 list 里面的数据上万,那么是直接一次性执行,还是分批次执行(比如每次更新 100 条)比较好 /

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5594 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 05:51 · PVG 13:51 · LAX 22:51 · JFK 01:51
    ♥ Do have faith in what you're doing.