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;
还没有评论,来说两句吧...