mybatis执行批量更新batch update 的方法(oracle,mysql)
2016-07-18 11:07
501 查看
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
<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数据库:
<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 违反协议 OALL8 处于不一致状态
- 11gr2 grid安装的时候,ASM磁盘status为Member
- oracle instr() 和substr()函数
- oracle 小问题之监听
- oracle 基础SQL语句 多表查询 子查询 分页查询 合并查询 分组查询 group by having order by
- 利用trunc函数定时刷新物化视图
- hdu-5718 Oracle(水题)
- 7-16 Bestcoder a Oracle
- 利用函数返回oracle对象表的三种方法
- oracle之order by
- python读取oracle函数返回值
- FIREDAC驱动ORACLE的配置
- oracle基础复习-2016.7.18
- python读取oracle函数返回值
- 利用函数返回oracle对象表的三种方法
- Oracle 数据泵是干什么的
- oracle/hive数据互导
- oraclelinux
- HDU 5718 Oracle
- hdu_5718_Oracle(大数模拟)