在迁移数据库后,有些表插入数据会报错:
ORA-00001: unique constraint … violated.
这是主键冲突的错误,如果该表有主键自增长,可以检查 oracle 的 sequence
select SEQUENCE_OWNER, SEQUENCE_NAME, MIN_VALUE, MAX_VALUE, INCREMENT_BY, CACHE_SIZE, LAST_NUMBER from all_sequences where SEQUENCE_OWNER = 'IRS';
假设 TEST_SEQUENCE 和实际的值相比偏小,可以先删除,然后重新创建
DROP SEQUENCE IRS.TEST_SEQUENCE; create sequence IRS.TEST_SEQUENCE minvalue 1 maxvalue 999999999999999999999999999 start with 165--起始值 increment by 1--增量 cache 20;
重新查询后可以看到 TEST_SEQUENCE的LAST_NUMBER变成了 165