加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle和mysql数据库的批量update在mybatis

发布时间:2020-12-12 15:35:04 所属栏目:百科 来源:网络整理
导读:转至:http://www.jb51.cc/article/p-qfmzocje-boy.html http://www.jb51.cc/article/p-aejbjcud-qt.html oracle和mysql数据库的批量update在mybatis中配置不太一样: oracle数据库: foreach collection="list" item="item" index="index" open="begin" clo

转至:http://www.52php.cn/article/p-qfmzocje-boy.html
http://www.52php.cn/article/p-aejbjcud-qt.html
oracle和mysql数据库的批量update在mybatis中配置不太一样:

oracle数据库:

<foreach collection="list" item="item" index="index" open="begin" close="end;" separator=";">
            update test 
            <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&characterEncoding=UTF-8&allowMultiQueries=true

<foreach collection="list" item="item" index="index" open="" close="" separator=";">
            update test 
            <set>
              test=${item.test}+1
            </set>
            where id = ${item.id}
     </foreach>

</update>

通用: update aa set a=#{fptm},b=#{csoftrain} where c in #{item}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读