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>
  • 相关阅读:
    字符串练习
    Python基础
    熟悉常见的Linux命令
    大数据概述
    实验三 递归下降分析法
    简化C语言文法
    实验一 词法分析程序实验
    词法分析程序
    制作首页的显示列表
    完成登录功能
  • 原文地址:https://www.cnblogs.com/hmhhz/p/13536443.html
Copyright © 2011-2022 走看看