This can be useful when you need to create a unique number to act as a primary key. The first sequence number that it would use is 1 and each subsequent number would increment by 1 (ie: 2,3,4,...}. If you omit the MAXVALUE option, your sequence will automatically default to: Now that you've created a sequence object to simulate an autonumber field, we'll cover how to retrieve a value from this sequence object.
To retrieve the next value in the sequence order, you need to use option specifies how many sequence values will be stored in memory for faster access.
When the system comes back up, Oracle will cache new numbers from where it left off in the sequence, ignoring the so called "lost" sequence values.
You can change the LASTVALUE for an Oracle sequence, by executing an ALTER SEQUENCE command.
NEXTVAL FROM dual; ALTER SEQUENCE gokhan.sample_seq INCREMENT BY 1; SELECT last_number FROM user_sequences WHERE sequence_name = 'SAMPLE_SEQ'; LAST_NUMBER ----------- 500 CREATE OR REPLACE PROCEDURE SYS.