mybatis执行批量更新batch update 的方法(oracle,mysql两种)

网友投稿 425 2023-06-19


mybatis执行批量更新batch update 的方法(oracle,mysql两种)

Oracle和mysql数据库的批量update在mybatis中配置不太一样:

oracle数据库:

<update id="batchUpdate" parameterType="java.util.List">

<foreach collection="list" item="item" index="index" open="begin" close="end;" separator=";">

update test

LhCKIS <set>

test=${item.test}+1

set>

where id = ${item.id}

foreach>

update>

mysql数据库:

mysql数据库采用一下写法即可执行,但是数据库连接必须配置:&allowMultiQueries=true

例如:jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&characterEncodiLhCKISng=UTF-8&allowMultiQueries=true

<update id="batchUpdate" parameterType="java.util.List">

<foreach collection="list" item="item" index="index" open="" close="" separator=";">

update test

<set>

test=${item.test}+1

set>

where id = ${item.id}

foreach>

update>

以上所述是给大家介绍的mybatis执行批量更新batch update 的方法(oracle,mysql两种),希望对大家有所帮助,如果大家有任何疑问请给我留言,会及时回复大家的。在此也非常感谢大家对我们网站的支持!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微信小程序 input输入框详解及简单实例
下一篇:微信小程序开发之Tabbar实例详解
相关文章

 发表评论

暂时没有评论,来抢沙发吧~