java.sql.SQLException:ORA-02289:序列不存在

柔光的暖阳◎ 2023-10-05 17:07 42阅读 0赞

Oracle不像mysql一样可以创建自增的主键ID,所在在需要某一字段或者是主键自增的时候,我们就需要在Oracle中创建序列
第一步:
创建序列

  1. create sequence PATIENT_SEQ
  2. minvalue 2000
  3. maxvalue 9999999999
  4. start with 2020
  5. increment by 1
  6. cache 20;
  7. # 序列名
  8. # 初始序号
  9. # 最大序号
  10. # 从2020开始计算
  11. # 每次增1
  12. # 缓存20个

第二步
在这里插入图片描述

  1. <insert id="insertSelective" parameterType="com.djhu.hiup.message.server.core.model.Patient">
  2. insert into HLHT_PATIENT
  3. <trim prefix="(" suffix=")" suffixOverrides=",">
  4. PK,
  5. <if test="msgId != null">
  6. MSG_ID,
  7. </if>
  8. </trim>
  9. <trim prefix="values (" suffix=")" suffixOverrides=",">
  10. PATIENT_SEQ.NEXTVAL,
  11. <if test="msgId != null">
  12. #{
  13. msgId,jdbcType=VARCHAR},
  14. </if>
  15. </trim>
  16. </insert>

补充:

查询序列

  1. select PATIENT_SEQ.nextval from dual;

删除序列

  1. drop sequence PATIENT_SEQ;

发表评论

表情:
评论列表 (有 0 条评论,42人围观)

还没有评论,来说两句吧...

相关阅读