Question

Any reason to prefer to seed a DB table from 0 rather than from 1?

I'm referring to the simple case when a new DB table is being created with a unique index column of type Int, and the developer can choose if the first entry in that identity column is a 0 or a 1.

Was it helpful?

Solution

Usually in SQL Server you start identity columns with 1.

It is a common practice to use DEFAULT NULL to 0 when the right side of LEFT JOIN isn't matched.

It's look as if the developer is thinking of identity column row as the index in a vector, this is a mistake, you can DELETE rows it will have holes.

OTHER TIPS

The default is normally 1.

Using 0 could be considered ambiguous, and I can't see any reason why you'd want to prefer 0 over 1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top