0

If auto increment is on, why we need to mention not Null, as the value will increment automatically from 1.

If auto increment is on, why we need to mention not Null, as the value will increment automatically from 1.

20th Jun 2018, 7:36 AM
Virendra Ramteke
Virendra Ramteke - avatar
1 ответ
+ 2
From my conceptual memory, so Google may have a better answer: autoincrement does not mean: "you cannot provide a value". I believe it means instead: "if you don't provide a value*, I will choose the next highest number for you". This would prevent automatic but not deliberate NULLs. Yes, autoincrement implies numeric types, but in languages with the concept of the absence of value (compare 0, which has a value and it has been set), you need to handle the value-unspecified case (not sure what happens if you autoincrement from NULL, maybe it's overloaded to be 1). Also, uniqueness... NULLs generally do not equal each other, so I believe they will cause trouble in unique keys. Autoincrement fields are very often intended to be unique row IDs. * Important. I believe nothing prevents you from skipping numbers on purpose.
20th Jun 2018, 4:35 PM
Kirk Schafer
Kirk Schafer - avatar