oracle和mysql批量合并对比

orm框架采用mybatis,本博客介绍一下批量合并merge用oracle和mysql来做的区别,

oracle merge合并更新函数的详细介绍可以参考我以前的博客:https://blog.csdn.net/u014427391/article/details/87898729

oracle方法:

<!-- 批量更新新增关联信息 oracle-->
    <insert id="batchSaveTipsRelatedConfig" databaseId="oracle" parameterType="com.extend.tipsConfig.model.TipsRelatedModel">
        MERGE INTO t_tips_config_related A1 
        USING(<foreach collection="relatedTipsList" item="itm" separator="union">select #{itm.seq} seq ,
                     #{itm.tipsSeq} tipsSeq , 
                     #{itm.relaSeq} relaSeq,
                     #{itm.tipsContent} tipsContent
                  from dual
            </foreach>) A2
        ON(A1.tips_seq = A2.tipsSeq and A1.rela_seq = A2.relaSeq)
        WHEN MATCHED THEN
        UPDATE SET
                A1.tips_content = A2.tipsContent
        WHEN NOT MATCHED THEN
        INSERT(seq , tips_seq ,  rela_seq, tips_content)
        VALUES(A2.seq , A2.tipsSeq ,A2.relaSeq, A2.tipsContent)
    </insert>

mysql方法:

<!-- 批量更新新增关联信息 mysql-->
    <insert id="batchSaveTipsRelatedConfig" databaseId="mysql" parameterType="com.extend.tipsConfig.model.TipsRelatedModel">
        REPLACE INTO t_tips_config_related(seq,tips_seq,rela_seq,tips_content)  
        VALUES<foreach collection="relatedTipsList" item="itm" separator=",">(#{itm.seq},
                     #{itm.tipsSeq}, 
                     #{itm.relaSeq},
                     #{itm.tipsContent})</foreach>
    </insert>
上一篇:electron打包后的图标锯齿解决办法


下一篇:electron-vue搭建桌面应用