Re: automatic unique key genration

From: W. van der Deijl <W.van.der.Deijl_at_inter.nl.net>
Date: 1995/11/22
Message-ID: <DIGuI1.I15_at_inter.NL.net>#1/1


Michael Hollingsworth <mholling_at_nova.umuc.edu> wrote:

>Does anyone know if oracle supports automatic key generation. I
>would like to have the primary key generated automatically as part of a
>trigger whenever a record is inserted. I know that some databases have
>this object/function built in as part of their SQL extensions.
What you could do is create a SEQUENCE. This would be something like CREATE SEQUENCE USER.SEQ_NAME
[INCREMENT BY 2]
[START WITH 100]; There are some other options (look in the manual or online DOC). The DOC says about create sequence: "Create a new sequence suitable for generation of primary keys". Sounds like this is exactly what you want.

Every time you ask the next value of a sequence you get a number. Oracle guarentees that this number won't be given twice, so it's guarenteed unique.

Bye,
Wilfred

>My company is moving to client/server and this feature would be nice.
 

>Thanks for any info.
 

>Mike

>***************************************************************************
>Michael Hollingsworth mholling_at_nova.umuc.edu
Received on Wed Nov 22 1995 - 00:00:00 CET

Original text of this message