oracle修改序列自增值alter sequence increment by

2020-04-24

序列值比表中最大值小,导致新插入id重复,比如数据库中100,seq.nextval值为100,思路是将自增值设置为800.执行一次让两个值相等。

1、alter sequence t1_ID_SEQ increment by 520;

2、SQL> select t1_ID_SEQ.nextval from dual;

SQL> select max(id) from t1;

3、SQL> alter sequence t1_ID_SEQ increment by 520;

SQL> select t1_ID_SEQ.nextval from dual;

NEXTVAL
----------
87743

4、SQL> Alter sequence t1_ID_SEQ Increment By 1;

Sequence altered.

SQL> select t1_ID_SEQ.nextval from dual;

NEXTVAL
----------
87744

分类:数据库 | 标签: |

相关日志

评论被关闭!