Multiple choice technology databases

Given the following ALTER SEQUENCE statement: ALTER SEQUENCE myseq RESTART WITH 0 INCREMENT BY 1 NO MAXVALUE CACHE 5 ORDER Assuming that the sequence had reached a value of 100 prior to the RESTART, which of the following is true?

  1. The next value will be 0 and the sequence will never use the values 101 to 105.

  2. The next value will be 101 to ensure uniqueness between existing and newly generated sequence values.

  3. Previously cached values are retained by DB2, and after the restart, will be used for values 101 to 105.

  4. The next value will be 0 and DB2 will not ensure uniqueness between existing and newly generated values.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

After ALTER SEQUENCE with RESTART WITH 0, the next value generated will be 0. DB2 does not guarantee uniqueness between previously used sequence values (like 101-105) and newly generated values after a restart. Options A, B, and C incorrectly suggest that cached values are retained or uniqueness is maintained - the RESTART command explicitly discards cached values and resets the sequence.

AI explanation

ALTER SEQUENCE ... RESTART WITH 0 resets the sequence's next-value counter to 0 immediately; it doesn't reconcile with values already generated or cached. With CACHE 5 in effect, any pre-allocated cached values (101–105) are simply discarded, and the engine makes no attempt to guarantee the newly restarted numbering (0, 1, 2, ...) won't collide with IDs already stored in dependent tables. So the next value is 0, with no uniqueness guarantee against pre-restart values — matching the correct option. (The option's mention of "DB2" appears to be a content typo, since ALTER SEQUENCE ... RESTART is Oracle syntax, but it doesn't change which answer is logically correct.)