unique constraint: Oracle ORA-00001 when you insert data

background:

the reason:

The tips of the index, the fields found in the table "SEQ_NO", as found by another test database is synchronized from the database, the sequence number in the table is automatically disrupted, leading to the next time data is inserted, sql automatic seat generate serial numbers where the data has been, resulting in a unique constraint error. Of course, wrong deletion of data and human errors operation will cause this problem.

solve:

First, we can check what the serial number of the table in what seat (my table TBL_ACM_CLAIM):
the SELECT from DUAL SEQ_ACM_CLAIM.NEXTVAL

Do not perform this sql, because no executed once, the index value will be incremented +1; to query results, existing data comparison table, comparison, if the value is greater than the table SEQ_NO queried value, you will the index value is updated, the setting sequence of step 100 (usually 1), execute the following SQL:
ALTER sequence SEQ_ACM_CLAIM by INCREMENT 100

Note: SEQ_ACM_CLAIM is not a table, there is the current value of the index value can not be changed, modified only increase, not decrease.

prompt:

Search all indexes:
the SELECT * from the USER_SEQUENCES;

Delete Index:
drop Sequence SEQ_ACM_CLAIM;
create an index:
the CREATE UNIQUE INDEX ON SEQ_ACM_CLAIM TBL_ACM_CLAIM (seq_no);

to sum up:

Delete library to run away, one second is enough.

Guess you like

Origin www.linuxidc.com/Linux/2019-05/158865.htm