一、 mysql:
方式一:
insert into user(id,name) VALUES (1,'a'),(2,'b');
方式二:
insert into user(id,name) VALUES (1,'a');
insert into user(id,name) VALUES (2,'b');
二、oracle:
方式一:
insert into T_USER(USER_ID,USER_NAME) VALUES (1,'a');
insert into T_USER(USER_ID,USER_NAME) VALUES (2,'b');
方式二:
BEGIN
insert into T_USER(USER_ID,USER_NAME) VALUES (1,'a');
insert into T_USER(USER_ID,USER_NAME) VALUES (2,'b');
END;
方式三:
//sql:
insert into T_USER(USER_ID,USER_NAME)
select 1,'a' FROM dual
union select 2,'b' FROM dual
<!--mybatis-->
<insert id="insertCostProTimesheetConfirmBatch" parameterType="com.andawell.ipd.platform.cost.domain.protime.entity.po.CostProTimesheetConfirmPO">
insert into COST_PRO_TIMESHEET_CONFIRM
( COST_PRO_TIMESHEET_CONFIRM_ID,TIME_SUM_YEAR,TIME_SUM_MONTH
,PRO_TIME_STATUS,TIME_REPORTER_ID,TIME_REPORTER_NAME
,SYS_ORG_ID,SYS_ORG_NAME,CREATED_BY
,CREATION_DATE,LAST_UPDATED_BY,LAST_UPDATED_DATE
,LAST_UPDATE_IP,VERSION)
<foreach collection="list" separator=" union " item="item" index="index">
select #{item.costProTimesheetConfirmId,jdbcType=VARCHAR},#{item.timeSumYear,jdbcType=VARCHAR},#{item.timeSumMonth,jdbcType=VARCHAR}
,#{item.proTimeStatus,jdbcType=VARCHAR},#{item.timeReporterId,jdbcType=VARCHAR},#{item.timeReporterName,jdbcType=VARCHAR}
,#{item.sysOrgId,jdbcType=VARCHAR},#{item.sysOrgName,jdbcType=VARCHAR},#{item.createdBy,jdbcType=VARCHAR}
,#{item.creationDate,jdbcType=TIMESTAMP},#{item.lastUpdatedBy,jdbcType=VARCHAR},#{item.lastUpdatedDate,jdbcType=TIMESTAMP}
,#{item.lastUpdateIp,jdbcType=VARCHAR},#{item.version,jdbcType=DECIMAL} from dual
</foreach>
</insert>
三、对比:
共同可用的方式:
insert into user(id,name) VALUES (1,'a');
insert into user(id,name) VALUES (2,'b');