Quick Search:
 
 Oracle PL/SQL: Create Sequence Jump to:  
Category: >> Oracle PL/SQL >> Create Sequence  

<< 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.

Language:
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.


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org