Why Oracle does not have autoincrement?

4

Assuming that Oracle is known to have the capabilities of the sequence table.

I would like to understand why I recently implemented autoincrement in Oracle, since it was an existing feature in competitors (SQL Server, MySQL). What motivated you to choose not to implement autoincrement features? To be sure this must have been debated a few times within the team, so it should have a logical reason.

I know there are ways to manually implement autoincrement , but I would like to understand what led them to relinquish the feature natively.

    
asked by anonymous 01.11.2017 / 13:23

1 answer

2

As of version 12c you can already use this feature. Take a look at this link .

Now, the exact reason for not implementing before, would only be possible to get through some note from Oracle itself, but an interesting "justification" addressed by Gary Myers in a similar question is:

  

It may just be terminology. "AUTOINCREMENT" implies that a   103 will be created between registers 102 and 104. In an environment of   clusters, this is not necessarily the case for sequences. A node can   insert 100, 101, 102 while another node is inserting 110, 111, 112,   so the records are "out of order". (Of course the term   sequence has the same implication.)

     

If you choose not to follow the sequence template, then you enter   blocking and serialization problems. You force an insert to wait   the commit / rollback of another insert before determining which is the   next value, or you accept this, if the transaction fails, you will have   a space between the keys.

     

Then there is the question of what you do if someone wants to insert a   row in the table with a specific value for that field (that is, it is   allowed or acts as a DEFAULT) or if someone tries   update it. If someone enters 101, autoincrement "jumps" to 102 or   you risk attempting duplicate values.

     

It may have implications for your IMP utilities and   direct path and backward compatibility.

     

I'm not saying it could not be done. But I suspect that in the   Someone looked at this and decided that they could spend time   developing something better elsewhere.

In short, a sequence can do what an autoincrement does and something else, and give the bank administrator more freedom to manipulate those values.

    
01.11.2017 / 14:07