zoukankan      html  css  js  c++  java
  • oracle批量插入自增问题【转】

    --1.创建序列
    create sequence seq_paper_choice
          increment by 1    -- 每次递增1
          start with 1       -- 从1开始
          nomaxvalue      -- 没有最大值
          minvalue 1       -- 最小值=1
          NOCYCLE;      -- 不循环
          
    --2.为序列创建触发事件
    create or replace trigger style_insert
      before insert on
    paper_choice (表名)
      for each row
    begin
      select seq_paper_choice.nextval into :new.id from dual;
    end;
    --注(不创建触发事件,以下批量插入序列号不会自增)
     
    --oracle 批量插入mybatis写法
    <!--批量新增-->
    <insert id="insertRandChoice" parameterType="java.util.List">
    INSERT ALL
    <foreach collection="list" item="item" index="index">
    INTO paper_choice (id,content, aoption,boption,coption,doption, answer ,examid)
    VALUES(seq_paper_choice.nextval,
    #{item.content,jdbcType=VARCHAR},
    #{item.aoption,jdbcType=VARCHAR},
    #{item.boption,jdbcType=VARCHAR},
    #{item.coption,jdbcType=VARCHAR},
    #{item.doption,jdbcType=VARCHAR},
    #{item.answer,jdbcType=VARCHAR},
    #{item.examid,jdbcType=DECIMAL})
    </foreach>
    SELECT 1 FROM DUAL
    </insert>
  • 相关阅读:
    CodeForces 734F Anton and School
    CodeForces 733F Drivers Dissatisfaction
    CodeForces 733C Epidemic in Monstropolis
    ZOJ 3498 Javabeans
    ZOJ 3497 Mistwald
    ZOJ 3495 Lego Bricks
    CodeForces 732F Tourist Reform
    CodeForces 732E Sockets
    CodeForces 731E Funny Game
    CodeForces 731D 80-th Level Archeology
  • 原文地址:https://www.cnblogs.com/hmhhz/p/13536443.html
Copyright © 2011-2022 走看看