CoderZone.org

Category: >> Oracle PL/SQL >> Create Sequence Bookmark and Share

<< lastnext >>

Snippet Name: Create Sequence

Description: This is the basic create statement for sequences.

Comment: INCREMENT can be by any integer.
START WITH can be any integer.
If you set a max number and choose CYCLE the sequence will start again at your STARTWITH value.

Author: CoderZone
Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 02nd, 2009

CREATE SEQUENCE test_seq
 INCREMENT BY 1
 START WITH 1
 NOMINVALUE
 NOMAXVALUE
 NOCYCLE 
 NOCACHE
 NOORDER 
 
USE OF sequence
 
INSERT INTO test_table (fld1, fld2, fld3)
VALUES (test_seq.NEXTVAL, SYSDATE, 'somestring')
 
After a sequence generates a VALUE BY using test_seq.NEXTVAL, you can USE 
test_seq.CURRVAL TO reuse that VALUE.
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 7