Oracle学习笔记03:oracle批量插入语句
首先,Oracle批量插入和Mysql批量插入语句格式是不一样;
Mysql语句,如下:
<insert id="save" parameterType="PlatformAssoRecord" keyColumn="id" keyProperty="id"> insert into S_PLATFORM_ASSO_RECORD( "id", "asso_a_id", "asso_b_id", "type", "status", "del_flag", "create_user_id", "create_time" ) values ( #{id}, #{assoAId}, #{assoBId}, #{type}, #{statu}, #{delFlag}, #{createUserId}, #{createTime} ) </insert>
Oracle语句,如下:
<insert id="saveBatch" parameterType="list" > insert ALL <foreach collection="list" item="item" separator=""> INTO S_PLATFORM_ASSO_RECORD( "id", "asso_a_id", "asso_b_id", "type", "status", "del_flag", "create_user_id", "create_time" ) values ( #{item.id, jdbcType=BIGINT}, #{item.assoAId, jdbcType=VARCHAR}, #{item.assoBId, jdbcType=VARCHAR}, #{item.type, jdbcType=INTEGER}, #{item.status, jdbcType=INTEGER}, #{item.delFlag, jdbcType=INTEGER}, #{item.createUserId, jdbcType=VARCHAR}, #{item.createTime, jdbcType=TIMESTAMP} ) </foreach> SELECT 1 FROM DUAL </insert>
其中
insert all into并不表示一个表中插入多条记录,而是表示多表插入各一条记录,而这多表可以是同一个表,就成了单表插入多条记录。
SELECT 1 FROM DUAL 的作用,可以参考博客:https://www.cnblogs.com/mingmingcome/p/9310371.html
参考资料:
1- https://blog.csdn.net/fukaiit/article/details/80691665
2- https://www.cnblogs.com/mingmingcome/p/9310371.html