Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: autoinc field

Re: autoinc field

From: Sybrand Bakker <postmaster_at_sybrandb.demon.nl>
Date: Tue, 5 Oct 1999 06:40:09 +0200
Message-ID: <939098500.29783.0.pluto.d4ee154e@news.demon.nl>


You need to use sequences to do this.
create sequence <sequence_name> will do the trick. To use the sequence, you need to have select privilege on the sequence (and of course as owner you automatically have). You have a currval and nextval with sequences. select sequence.nextval from dual
will increment the sequence.
select sequence.currval from dual
will show the current value.
You can't use currval if you didn't use nextval in the same session before. In an insert statement you would get
insert into emp
values (sequence.nextval, 'Scott')
and so on.
A sequence is not bound to a particular table.

Hth,

--
Sybrand Bakker, Oracle DBA
Bill Portellie <bill_at_sysbase.com> wrote in message news:37F97D59.FBF66D93_at_sysbase.com...
> Is it possible to create an autoincrement field in oracle and if so how?
>
> Thanks in advance
>
Received on Mon Oct 04 1999 - 23:40:09 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US