Oracle序列更新为主键最大值

编程

在测试库运行时,发现ORA-00001: 违反唯一约束条件,查找发现是因为序列没有备份成功,需要更新序列值

DECLARE

vnumber NUMBER;

nnumber NUMBER;

BEGIN

SELECT ((SELECT max(t_jc_position.jc_position_id) FROM T_JC_POSItion) -

SEQ_JCPOSITION_ID.nextval)

INTO vnumber

FROM dual;

IF vnumber > 0 THEN

EXECUTE IMMEDIATE "ALTER SEQUENCE SEQ_JCPOSITION_ID INCREMENT BY " ||

vnumber;

SELECT SEQ_JCPOSITION_ID.nextval INTO nnumber FROM dual;

EXECUTE IMMEDIATE "ALTER SEQUENCE SEQ_JCPOSITION_ID INCREMENT BY 1 cache 20";

END IF;

END;

 

以上是 Oracle序列更新为主键最大值 的全部内容, 来源链接: utcz.com/z/514785.html

回到顶部