I created an Oracle sequence:
Create sequence seq_acteurs start with 1 increment by 1;
Normally the sequence must be incremented by 1, but when insert into Acteurs
table, the sequence s
incremented by 50! That doesn't seem logical. Why is this so?
Any help will much apreciated.
INCREMENT BY Specify the interval between sequence numbers. This integer value can be any positive or negative integer, but it cannot be 0. This value can have 28 or fewer digits. The absolute of this value must be less than the difference of MAXVALUE and MINVALUE .
To decrement sequence, set the value for INCREMENT BY to a negative number. Setting INCREMENT BY to -1 decrements the sequence object by 1.
Specifies the largest value the sequence number can reach. The default is NOMAXVALUE, which means the maximum value is 10 27.
CACHE. Specify how many values of the sequence the database preallocates and keeps in memory for faster access. This integer value can have 28 or fewer digits. The minimum value for this parameter is 2. For sequences that cycle, this value must be less than the number of values in the cycle.
Sequence numbers are not fetched one at a time when you need them. NOrmally, the DB caches a certain number of sequence numbers in memory. WHen the cached sequences are all used up, then the DB fetches a new block of sequence numbers into cache. Now if the DB crashes for some reason while the cache still has some unused numbers, then there could be some gaps in your sequence numbers.
Sequences does not guarantee that they generate a gap free sequence of numbers.
You can minimize the gaps by specifying nocache
, but this does still not guarantee gap free sequences, and might create a resource contention.
Example from the documentation:
CREATE SEQUENCE customers_seq START WITH 1000 INCREMENT BY 1 NOCACHE NOCYCLE;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With