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: Dirk Wendt <Dirk.Wendt_at_darmstadt.netsurf.de>
Date: 2000/06/04
Message-ID: <8hc2q1$2oa6a$1@fu-berlin.de>#1/1

Hello,
Echoes <echoes_at_free.fr> schrieb in im Newsbeitrag: 3934D935.D829B53D_at_free.fr...
> 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 ?

CREATE SEQUENCE Forum_Forum_ID_SEQ
increment by 1
start with 1
maxvalue 999999
minvalue 0
cyle
nocache
noorder;

CREATE OR REPLACE TRIGGER SET_Forum_Forum_ID BEFORE INSERT ON FORUM for each row
begin
SELECT Forum_Forum_ID_SEQ.NEXTVAL INTO :New.Forum_ID FROM DUAL; end;

#Forum.Forum_ID represents an "autoinc-field" in table Forum, column Forum_ID.

Ciao, Dirk. Received on Sun Jun 04 2000 - 00:00:00 CDT

Original text of this message

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