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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Autoincrement field

Re: Autoincrement field

From: Mark D Powell <markp7832_at_my-deja.com>
Date: 2000/05/31
Message-ID: <8h33lq$6bv$1@nnrp1.deja.com>#1/1

In article <3934D935.D829B53D_at_free.fr>,
  Echoes <echoes_at_free.fr> wrote:
> Hello,
>
> I'm new at Oracle usage, and i'm looking for
> something i used with mysql:
>
> I have a number field in a table, and I want it to be
> incremented for each new insertion, making it a unique
> key for this table. With mysql I just have to specify
> an AUTO_INCREMENT option for the field, but with Oracle ?
>
> Thanks
>
> Eugene
>

Oracle like most other major rdbms products, example DB2, generates keys rather than declares them as a non-ANSI datatype or class.

See CREATE SEQUENCE in the SQL manual for available options:

create sequence my_seq;

insert into my_table (key, col2, col3)
values (my_seq.nextval,'SOMEDATA',sysdate);

Nextval is basically a function that generates a numeric value based on the parameters set when it was defined by the create sequence command.

--
Mark D. Powell  -- The only advice that counts is the advice that
 you follow so follow your own advice --


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Wed May 31 2000 - 00:00:00 CDT

Original text of this message

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