Ron McLeod wrote:If the ID column is AUTO_INCREMENT then you should not be trying to insert anything in to that column (null or otherwise).
And if you do insert a value for an auto-increment column, the common database behavior is that it will set that value
instead of using the next available auto-increment value.
And if that value conflicts with an existing value and the column is defined as unique (as, for example a primary key), then the insert will fail.
And if a later auto-increment operation would set a unique column value to that existing value, then
if you are lucky then the auto-increment manager in the DBMS will detect the collision and skip over it, selecting a new auto-increment value. But if you are not, the insert for the auto-incremented value will fail. As far as I know, there's not defined standard on which will happen, so depending on the DBMS vendor and version, consider the results as unpredictable.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.