Subject: Re: Generators for Primary Keys
References: <>

Uwe Grauer ( wrote:
: Does Oracle support Generators (gen_id) to get unique
: Integers for Primary Keys?
: If not, how do People get unique Integers for Primary Keys?
: TIA,
: 	Uwe


Use a SEQUENCE to generate unique numbers for your primary keys. Oracle
handles sequences very well in regards to data consistency... when
transactions are rolled back, the sequence does not "roll back" to an
earlier value.

To fully explain sequences is beyond the scope of a simple post, but I
will show the basic commands below:

create sequence UWE_SEQUENCE start with 1 maxvalue 999999 increment by 1;

FIND THE CURRENT VALUE (without incrementing):
select UWE_SEQUENCE.CURRVAL from dual;

FIND THE NEXT VALUE (and increment):
select UWE_SEQUENCE.NEXTVAL from dual;

-Ari Kaplan
Independent Oracle DBA Consultant

<-> For 70+ technical tips, visit my Web Page:                    <->
<->                                                               <->
<->                                    <->
<->                                                               <->
<->             email:                    <->

Back to Ari Kaplan's Home Page m">Back to Ari Kaplan's Home Page