Re: Autonumber in Oracle

From: Jim West <Jim.West_at_mci.com>
Date: Thu, 23 Sep 1999 13:42:27 GMT
Message-ID: <ly3qNytMf97acd6V=6e1=SQ8VH0J_at_4ax.com>


On Wed, 22 Sep 1999 04:16:28 -0400, "Mike Phillips" <mlp_at_swsdot.com> wrote:

I believe you want to use a sequence.

create sequence pk nocache start with 1;

Then to use this...

select pk.nextval into table.pk from dual;

Note that there are some drawbacks with sequences. If you require no gaps then you'll have issues if you delete rows since sequences won't reuse those values.

>Question: Is there autonumber functinality in oracle like in access? Also,
>is it still a good idea then,
>to create a separate artificial recordID (autonumber) column for each table
>as the primary key. Or should we actually use real column values, for eg.:
>the combination of 'PartNumber+VendorID' values as the primary key for the
>tables, keeping in mind that in the end all records in a relational table
>must be unique. I personally liked the autonumber
>idea in MSAccess.
>
>Mike
>
>
>
Received on Thu Sep 23 1999 - 15:42:27 CEST

Original text of this message