mybatis执行批量更新batch update 的方法(oracle,mysql)
2015-06-02 10:59
253 查看
oracle和mysql数据库的批量update在mybatis中配置不太一样:
oracle数据库:
mysql数据库:
mysql数据库采用一下写法即可执行,但是数据库连接必须配置:&allowMultiQueries=true
例如:jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
oracle数据库:
<update id="batchUpdate" parameterType="java.util.List"> <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
<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>
相关文章推荐
- Oracle表分区(经典)
- oracle 的rowid和rownum
- 统计Oracle数据库文件的大小
- oracle 数据库 日期
- oracle 开机自动启动
- Oracle 死锁的检测查询及处理
- Oracle EBS R12.2 修改APPS密码方法
- 彻底删除oracle的方法
- Oracle中merge into的使用
- Oracle EBS R12.2 新特性文档
- oracle 数据导出导入序列不一致问题
- 笨拙而诡异的 Oracle
- 夜维执行慢的原因探究
- 关于spotlight for Windows和spotlight for oracle的使用
- oracle锁一些知识
- 在OEL 5.8上安装oracle database 10.2.0.1
- Oracle异常恢复前备份保护现场建议—FileSystem环境
- Oracle异常恢复前备份保护现场建议—ASM环境
- Oracle之内存结构(SGA、PGA)
- 自己动手 CentOS-6.5 安装Oracle11g R2