Wednesday, June 23, 2010

Create Sequence On Oracle

You can create for auto increment number/ID creation. Oracle generates sequence of number depend upon our code boundary.

Syntax:
CREATE SEQUENCE SEQUENCE_NAME
        MINVALUE VALUE        ( Assign Minimum Value )
        MAXVALUE VALUE        ( Assign Maximum Value )
        START WITH VALUE    ( Assign Start Value )
        INCREMENT BY VALUE;    ( Assign Increment Value )

For example:
CREATE SEQUENCE DUMMY_SEQUENCE
    MINVALUE 1
    MAXVALUE 10000
    START WITH 1
    INCREMENT BY 1
    CACHE 20;

Usage:
    DUMMY_SEQUENCE.NEXTVAL

Inside Query
INSERT INTO DUMMY_PERSONAL_DTLS
(DUMMY_ID,DUMMY_FNAME,DUMMY_LANME)
VALUES
(DUMMY_SEQUENCE.NEXTVAL,'RAJINI','THIYAGARAAJ');

1 comment:

Christy Sutharsanam said...
This comment has been removed by a blog administrator.