Re: Serial/Auto-number Field

From: David Lee <david_at_cbmsun.cbmisi.com>
Date: 1996/11/22
Message-ID: <3295A996.22B0_at_cbmsun.cbmisi.com>#1/1


Yudong Sun 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

The equivalent database object in Oracle is called a sequence. The syntax for creating a sequence named 'testseq', which starts at 1 and is incremented by 1 is:

  create sequence testseq increment by 1 start with 1;

The sequence is referenced as follows:    

   select testseq.nextval from dual;

There are several other options described in the SQL Language Reference Manual by Oracle.

-- 
David Lee
CBM Information Systems
Received on Fri Nov 22 1996 - 00:00:00 CET

Original text of this message