zoukankan      html  css  js  c++  java
  • Oracle 批量插入

    批量插入

    • 方式一 insert all into table(...) values(...) into table(...) values(...) select * from dual;
    <insert id="addList" parameterType="java.util.List" useGeneratedKeys="false">
            INSERT ALL
            <foreach item="item" index="index" collection="list">
            INTO T_APPLAUD
            (
                ID,
                USER_ID,
                BUSINESS_TYPE,
                PRODUCT_ID,
                CREATE_TIME
            ) VALUES
            (
                #{item.id, jdbcType=NUMERIC},
                #{item.userId, jdbcType=VARCHAR},
                #{item.businessType, jdbcType=VARCHAR},
                #{item.productId, jdbcType=VARCHAR},
                #{item.createdTime, jdbcType=NUMERIC}
            )
            </foreach>
            SELECT 1 FROM DUAL
        </insert>
    
    • 方式二 insert into table(...) (select ... from dual) union all (select ... from dual)
    <insert id="addList" parameterType="java.util.List" useGeneratedKeys="false">
            INSERT INTO T_APPLAUD
            (
                ID,
                USER_ID,
                BUSINESS_TYPE,
                PRODUCT_ID,
                CREATE_TIME
            )
            <foreach item="item" index="index" collection="list" separator="union all">
            (
                SELECT
                    #{item.id},
                    #{item.userId},
                    #{item.businessType},
                    #{item.productId},
                    #{item.createdTime}
                FROM DUAL
            )
            </foreach>
        </insert>
    
  • 相关阅读:
    「LibreOJ β Round #4」子集
    「LibreOJ β Round #4」框架
    「LibreOJ β Round #4」游戏
    [HNOI2008]GT考试
    [HNOI2008]水平可见直线
    UVA 1650 Number String
    [USACO14JAN]Recording the Moolympics
    UVA 1390 Interconnect
    UVA 12520 Square Garden
    [HNOI2008]神奇的国度
  • 原文地址:https://www.cnblogs.com/format-ch/p/14845958.html
Copyright © 2011-2022 走看看