Posted by: techGuy June 4, 2008
SQL Automatic incremental generator
Login in to Rate this Post:     0       ?        

If you mean this...

http://www.cs.rpi.edu/~sibel/dbs/FALL2003/system_info/oracle/unique.htm

How to generate a unique number (SEQUENCE)?

Oracle has solved a problem of assigning unique numbers (i.e.: studentID) without having to create a special table and handle update an concurrence it by using CREATE SEQUENCE:

In SQL*PLUS create a sequence generator

CREATE   SEQUENCE   sID
INCREMENT   BY   1
START   WITH   100
ORDER;

This will create a sequence that can be accessed by insert and update statements. Typically, the sequence is created with a statement like the following.

For sqlplus to insert into a table.

INSERT   INTO   student   (studentID, name, address)
values   (sID.NextVal, 'Albert', '123, Sage Ave., NY. 12180');

The NextVal attached to studentID tells Oracle you want the next available sequence number from the studentID sequence. This is guaranteed to be unique.

To use the current number (i.e., the same number more than once), CurrVal is used instead of NextVal.

Read Full Discussion Thread for this article