What is CYCLE/NO CYCLE in a Sequence


Answer posted by Scott on 2005-05-25 18:39:48: When you create a sequence with CYCLE option, you are saying that when the sequence reaches its MAXVALUE, it will start over at the MINVALUE. This is not wise if using the sequence for primary key creation. 
 
When you create a sequence with NOCYCLE option, you are saying that when the sequence reaches its MAXVALUE, it will NOT start over at the MINVALUE. This option is safest if using the sequence for primary key creation. When the sequence reaches its MAXVALUE an oracle error is thrown.

Showing Answers 1 - 14 of 14 Answers

Scott

  • May 25th, 2005
 

When you create a sequence with CYCLE option, you are saying that when the sequence reaches its MAXVALUE, it will start over at the MINVALUE. This is not wise if using the sequence for primary key creation. 
 
When you create a sequence with NOCYCLE option, you are saying that when the sequence reaches its MAXVALUE, it will NOT start over at the MINVALUE. This option is safest if using the sequence for primary key creation. When the sequence reaches its MAXVALUE an oracle error is thrown.

  Was this answer useful?  Yes

inam

  • May 26th, 2006
 

when a sequence is created with CYCLE option, this mean that when a sequence reaches its MAXVALUE, it will start over at the MINVALUE. The CYCLE option is not wise for the primary key column.

And when a sequence is created with NOCYCLE option, this mean that when the sequence reaches its MAXVALUE, it will not start over at the MINVALUE but an error is generated by the oracle server.

Note: Because CYCLE/NOCYCLE value is optional, When no option is defined, the default value will NOCYCLE.

  Was this answer useful?  Yes

kiranapps

  • Jun 24th, 2010
 

no cycle: The sequence cannot generate more values after the max value is reached.

cycle: The sequence can generate more values after the max value is reached

If max value is 1000 then if cycle is specified after reaching 1000 it will increment to next value 1001 if increment is 1.
For no cycle it will stop at 1000.

deepanath

  • Aug 15th, 2012
 

Sequence is SHOULD start from MINVLUE as per common logic. BUT it goes back to 1. anyone tried that ? I DID

  Was this answer useful?  Yes

feliz

  • Aug 15th, 2016
 

Kirnapps, this is not correct - CYCLE will restart with the minvalue again - it will not go past the maxvalue, as kiranapps post reply states.

  Was this answer useful?  Yes

rahul

  • Aug 6th, 2017
 

I tried ....sequence will start from 1

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions