Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Why Oracle don't have AUTO_INCREMENT as in MySQL
In message <58sq6eF2im0qmU1_at_mid.individual.net>, Robert Klemme
<shortcutter_at_googlemail.com> writes
>On 15.04.2007 10:12, howa wrote:
>> On 40 >>> On Apr 14, 7:27 am, "howa" <howac..._at_gmail.com> wrote:
>>>
>>>> Seems AUTO_INCREMENT is very handy and natural, anyone agree?
>>> Seems SEQUENCE is very handy and natural. Why don't others implement
>>> SEQUENCE?
>>>
>>> /Hans
>> I can't agree SEQUENCE is more handy than AUTO_INCREMENT as you need
>> to do the same thing by two statements.
>
>That depends on how you do it. There is
>
>insert into .... values ( ...., seq_xyz.next_val, ... )
>
> robert
One of the key (hehe) advantages sequences have over autoincrement is
currval. IIRC, in MSSQLServer, to get hold of the id you just inserted
into the parent table to put it into a child table you need to use one
of several variations of @@INSERTED (or something like that). This
returns the last number allocated - but not necessarily in your session
or in your table.
-- Jim Smith Ponder Stibbons Limited <http://oracleandting.blogspot.com/> RSS <http://oracleandting.blogspot.com/atom.xml>Received on Sun Apr 22 2007 - 03:29:33 CDT