Oracle批量插入
insert into tableName(col1, col2, col3)
select '第一行第一列值', '第二列值', '第三列值' from dual union
select ' 第二行第一列值 ', '第二列值', '第三列值' from dual union
select ' 第三行第一列值 ', '第二列值', '第三列值' from dual;
mybatils
INSERT INTO GSG_KERNEL_GMSISDN_TAB (STARTMS,ENDMS,AREACODE)
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT #{item.startMs,jdbcType=VARCHAR},
#{item.endMs,jdbcType=VARCHAR},
#{item.areaCode,jdbcType=VARCHAR} FROM DUAL
</foreach>
INSERT INTO CUSTOMER_SEND_INFO
(ID ,
EXPRESS_CODE ,
EXPRESS_NUM ,
CUSTOMER_CODE )
<iterate conjunction="UNION">
SELECT #customerSendInfoDtos[].id#,
#customerSendInfoDtos[].expressCode#,
#customerSendInfoDtos[].expressNum#,
#customerSendInfoDtos[].customerCode# FROM DUAL
</iterate>
MySql批量插入
insert into tableName(colName1, col2, col3...) values
('colName1', 'colName2','colName3' ),
('colName1', 'colName2','colName3' );
INSERT INTO tableName (colName1,colName2,colName3)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{attr1}, #{attr2}, #{attr2})
</foreach>