Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Sequence/autonumber
"Kalle W" <kawi9365NOkaSPAM_at_student.uu.se.invalid> wrote in message
news:05c2deba.b95c4f8f_at_usw-ex0105-035.remarq.com...
>
> How do I accomplish what in other database-engines are called
> autonumber? Like in Access for example. That is unique
> generation of indexes/record-keys. Is there a datatype that
> manages this automatically?
>
> /Kalle W
>
>
>
>
> -----------------------------------------------------------
>
> Got questions? Get answers over the phone at Keen.com.
> Up to 100 minutes free!
> http://www.keen.com
>
No, you'll need to use a sequence and either use
insert into table foo
values (fooseq.nextval...)
or create a before insert for each row trigger on foo assigning
fooseq.nextval to :new.<primarykeycolumn>
This approach may look cumbersome, but the advantage is a sequence is not bound to one single table.
Hth,
Sybrand Bakker, Oracle DBA Received on Mon Jul 24 2000 - 00:00:00 CDT