Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SERIAL data type
A copy of this was sent to "Alberto Lago da Silva"
<alberto.lagodasilva_at_abrantina.pt>
(if that email address didn't require changing)
On Mon, 7 Sep 1998 19:29:33 +0100, you wrote:
>Hi,
>
>How do I create de equivalent of the Informix SERIAL data type with Oracle 8
>and Oracle 7.3.
>
>Thanks in advance
>
>als
>
You need a sequence and a trigger -- it would look like this:
create table T1 ( x int primary key, .... );
create sequence t1_x_seq;
create trigger t1_trigg
after insert on t1 for each row
begin
select t1_x_seq.nextval into :new.x from dual;
end;
/
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
--
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Mon Sep 07 1998 - 14:06:06 CDT