Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Help on identity column
You need to create a separate sequence. A sequence is not bound to a
specific table, which can come in very handy.
You need to use either insert into table values (sequence.nextval) and/or
create a before insert trigger after each row, testing the primary key and
assigning sequence.nextval when the pk is still null.
Hth,
--
Sybrand Bakker, Oracle DBA
Larry Coon <lmcoon_at_home.com> wrote in message news:3863C2A8.1AD1_at_home.com...
> If somebody could help a Sybase user, I'd appreciate
> it. I want to create a table in Oracle 8 where the
> numeric primary key has the eqivalent of Sybase's
> "identity" property. That is, the system automatically
> maintains a sequential counter. Eg, in Sybase:
>
> create table my_table (
> key_col numeric(10) identity,
> non_key_col char(10)
> )
>
> With the "identity" property, Sybase will automatically
> generate the value for key_col, using 1, 2, 3, etc.
>
> How is this done in Oracle 8?
>
> Thanks,
>
> Larry Coon
> lmcoon_at_home.com
Received on Fri Dec 24 1999 - 14:08:33 CST
![]() |
![]() |