Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Autoincrement field
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