Re: Serial/Auto-number Field
Date: 1996/11/22
Message-ID: <57435b$lb2_at_newton.pacific.net.sg>#1/1
Yudong Sun <ysun_at_econnect.ca> wrote:
>Sorry to bother you with a simple question.
>What is the ORACLE equiv. to other DBMS's Serial or Auto-number
>field type. I remember vaguely that I needed to create
>a table and then did a select on this table to get a unique
>number each time. What's the syntax then?
>
>Thanks a lot
>
>Yudong
Hi there,
What you need is 'SEQUENCE'.
The syntax for creating sequence is
create sequence seq_1;
This is more than enough. You have the option of specifying initial value, max value, increment by what number and whether you want to cycle (after reaching maximum value should be start again from min value) and other things. The details are in SQL Reference manual.
You can issue the following query to select the next value from a sequence.
select seq_1.nextval
from dual.
Regards
N.Prabhakar Received on Fri Nov 22 1996 - 00:00:00 CET