mybatis foreach批量插入数据:Oracle与MySQL区别
2024-08-27 20:55:38
mybatis foreach批量插入数据:Oracle与MySQL不同点:
- 主要不同点在于foreach标签内separator属性的设置问题:
- separator设置为","分割时,最终拼接的代码形式为:insert into table_name (a,b,c) values (v1,v2,v3) ,(v4,v5,v6) ,...
- separator设置为"union all"分割时,最终拼接的代码形式为:insert into table_name (a,b,c) values (v1,v2,v3) union all (v4,v5,v6) union all...
- 详情请见示例代码:
Oracle:
<insert id="inserData" parameterType="com.test.aaa.Bac">
insert into table_name (name, adress, age)
values
<foreach collection="list" item="item" index="index" separator="union all">
(select #{item.name},
#{item.adress},
${item.age}
from dual )
<foreach>
</insert>
MySQL:
<insert id="inserData" parameterType="com.test.aaa.Bac">
insert into table_name (name, adress, age)
values
<foreach collection="list" item="item" index="index" separator=",">
( #{item.name}, #{item.adress}, ${item.age} )
<foreach>
</insert>
最新文章
- 【CentOS】LAMP相关3
- SQL 数字分割的字符串
- HIFI播放器--磨机吐槽篇
- MyEclipse无法启动调试:Cannot connect to VM
- JAVA基础学习之throws和throw的区别、Java中的四种权限、多线程的使用等(2)
- Get Many Persimmon Trees_枚举&;&;二维树状数组
- <;转>;单播,广播,组播的缺点与优点
- WWDC 2016: Rich Notifications in iOS 10
- CodeForces 609A USB Flash Drives
- div内部元素居中
- yum安装phpmyadmin小问题
- 面向对象object与constructor
- php 逗号 explode分割字符串 或 implode组装成字符串
- IIS日志存入数据库之一:ODBC
- tensorflow进阶篇-4(损失函数3)
- Vue之组件使用(一)
- 强制开启android webview debug模式使用Chrome inspect
- python-day21--os模块
- 文本操作 $(..).text() $(..).html() $(..).val()最后一种主要用于input
- Hibernate入门级实例
热门文章
- 《Head First 设计模式》【PDF】下载
- iOS学习之Socket使用简明教程- AsyncSocket
- 关于《ASP.NET MVC企业级实战》
- Handler的解析和使用
- laravel框架一种方便的快速填充数据的方法
- ABP 教程文档 1-1 手把手引进门之 AngularJs, ASP.NET MVC, Web API 和 EntityFramework(官方教程翻译版 版本3.2.5)含学习资料
- VS 2017 Web项目需要安装Sql Server 2012 Express LocalDB问题
- 麻瓜之我要学sql,啦啦啦啦
- JDK并发包常用的知识图
- 快速恢复开发环境(系统还原后的思考,附上eclipse注释的xml配置文件)