Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: SEQUENCE: Create sequence demo Jump to:  
Category: >> Oracle PL/SQL >> SEQUENCE: Create sequence demo Bookmark and Share

<< lastnext >>

Snippet Name: SEQUENCE: Create sequence demo

Description: A sequence is an object in Oracle that is used to generate an autonumber field (a number sequence). This is often used to create a unique number to act as a primary key.

Also see:
» SEQUENCE: Demo code and Examples
» SEQUENCE: Find sequence MAX value
» SEQUENCE: Reset a sequence to a predef...
» SEQUENCE: get sequence value into vari...
» SEQUENCE: Autonumber into two tables

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 06th, 2009

CREATE SEQUENCE sequence_name
    MINVALUE VALUE
    MAXVALUE VALUE
    START WITH VALUE
    INCREMENT BY VALUE
    CACHE VALUE;
 
-- If you omit the MAXVALUE option, your sequence will 
-- automatically default to:
 
    MAXVALUE 99999999999999999999999999
 
 
-- create sequence demo:
 
CREATE SEQUENCE supplier_seq
     MINVALUE 1
     MAXVALUE 999999999999999999999999999
     START WITH 1
     INCREMENT BY 1
     CACHE 20;
 
Sequence created.
 
 
 SELECT supplier_seq.NEXTVAL FROM dual;
 
   NEXTVAL
----------
         1
 
 SELECT supplier_seq.NEXTVAL FROM dual;
 
   NEXTVAL
----------
         2
 
 SELECT supplier_seq.NEXTVAL FROM dual;
 
   NEXTVAL
----------
         3
 
 SELECT supplier_seq.NEXTVAL FROM dual;
 
   NEXTVAL
----------
         4
 
 
DROP sequence supplier_seq;
 
Sequence dropped.


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 217 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?