Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Autoincrement field
In article <8h0uu1$b64$17$1_at_news.t-online.com>,
"Rainer Hagemann" <Rainer.Hagemann_at_t-online.de> wrote:
> Hello to all from Minden/Germany
>
> did someone know how i can create an
> autoincrement field ( in informix it is an serial type) in
> a oracle database table.
>
> Thank you in advance
>
> Rainer
>
>
we use sequences for that:
create sequence myseq;
create trigger my_trigger
before insert on T for each row
begin
if ( :new.column_to_fill_in is null ) then
select myseq.nextval into :new.column_to_fill_in from DUAL;
end if;
end;
/
-- Thomas Kyte (tkyte_at_us.oracle.com) Oracle Service Industries Howtos and such: http://osi.oracle.com/~tkyte/index.html Oracle Magazine: http://www.oracle.com/oramag Opinions are mine and do not necessarily reflect those of Oracle Corp Sent via Deja.com http://www.deja.com/ Before you buy.Received on Tue May 30 2000 - 00:00:00 CDT
![]() |
![]() |