Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Why Oracle don't have AUTO_INCREMENT as in MySQL

Re: Why Oracle don't have AUTO_INCREMENT as in MySQL

From: Galen Boyer <galen_boyer_at_yahoo.com>
Date: 24 Apr 2007 21:40:07 -0500
Message-ID: <ur6q9yp5m.fsf@rcn.com>


On Mon, 23 Apr 2007, damorgan_at_psoug.org wrote:

> Malcolm Dew-Jones wrote:

>> DA Morgan (damorgan_at_psoug.org) wrote:
>> : Galen Boyer wrote:
>> : >> The Oracle sequence is a far more intelligent way to solve
>> the
>> : >> problem.
>> : > : > The Oracle sequence is a far more powerful object that
>> can be used to
>> : > mimic autoincrementing keys. But that doesn't make it easier to
>> : > implement for the developers.
>> : If a developer can't handle
>> : INSERT INTO t
>> : (idcol)
>> : VALUES
>> : (idseq.NEXTVAL);
>> : Then they should learn to say 'do you want fries with that'.
>> : I hate to be a bit harsh here but it isn't exactly like asking
>> : them to step up to a real hardship like curly braces or assembler.
>> All true, but never the less the typical programmer error will
>> be
>> something like
>> INSERT INTO tablexyz
>> (idcol)
>> VALUES
>> (sequencexy.NEXTVAL)
>> which will likely work for while, but later cause a mysterious
>> bug that
>> takes an hour to track down and fix.
>> it would be nice to be able to say something like
>> create table xyz
>> ( idcol default eval('sequencexyz.NEXTVAL')
>> );
>> ,,, sort of a kind of declarative trigger.
>> $0.10

>
> Well Ok. I'll but it the way you wrote it.

Thats all the argument was saying. Nice example Malcolm.

> But to be honest I have never once, in more than a decade of Oracle, > ever seen anyone choose the wrong sequence.

And it usually won't matter if they do.

-- 
Galen Boyer
Received on Tue Apr 24 2007 - 21:40:07 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US