Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: Create Sequence Jump to:  
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.

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.


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 167 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?