orcale与mysql批量插入方式对比

一、 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');
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值