We need to make him self-increment when using Oracle to create a primary key, but unlike MySQL, you need to create a sequence that looks like this:
You can delete the previously created sequence, and we re-create one:
DROP SEQUENCE sjgxqk_sequence; --Delete
Create sequence Sjgxqk_sequence--(Sjgxqk_sequence, this represents the name of your sequence)
INCREMENT by 1--add a few each time
Start with 1-counting starting from 1
Nomaxvalue--Do not set the maximum value
Nocycle--keep accumulating, not looping
CACHE 10; --cache can be used to improve the acquisition speed of sequential values, but it is possible to waste some serial numbers, and the cache size should be set according to the actual situation. This specific I do not know how to use, refer to others to share, haha
Then query under:
Select Sjgxqk_sequence.nextval from dual; Look at him. What is the ID of the next auto-insert?
It is possible that the result value is Nextval = 1; This means that he will automatically insert the ID from "1".
Before this we may have old data, this ID does not necessarily start from 1, it may have been sorted to 10, 20.
At this point we need to change the starting value of his:
alter sequence sjgxqk_sequence increment by; (from 14 onwards, this 14 is based on your needs)
alter sequence sjgxqk_sequence increment by 1; (Increment one at a time)
So after that they won't be prompting us: violating the unique constraints haha haha ~
Welcome reprint, Mutual encouragement.
End
Resolving conflicts with old data IDs when Oracle inserts data