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

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

create sequence PATIENT_SEQ 
minvalue 2000           
maxvalue 9999999999    
start with 2020         
increment by 1         
cache 20;               

# 序列名
# 初始序号
# 最大序号
# 从2020开始计算
# 每次增1
# 缓存20个

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

 <insert id="insertSelective" parameterType="com.djhu.hiup.message.server.core.model.Patient">
        insert into HLHT_PATIENT
        <trim prefix="(" suffix=")" suffixOverrides=",">
            PK,
            <if test="msgId != null">
                MSG_ID,
            </if></trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            PATIENT_SEQ.NEXTVAL,
            <if test="msgId != null">
                #{msgId,jdbcType=VARCHAR},
            </if></trim>
    </insert>

补充:

查询序列

select PATIENT_SEQ.nextval from dual;

删除序列


drop sequence PATIENT_SEQ;

版权声明:本文为weixin_43811057原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。