was wondering, why does the SQL primary key index begin at 1, and why not at 0 ? Is there a reason ?
I don't know if this is the good place to ask a question like this, but found no answer on the web.
Counting in SQL generally starts as "1". For instance, the substring operations count characters in a string from 1 (and not 0). row_number()
enumerates rows in a group, starting from 1 (and not 0).
The reason for this is simple. Humans start counting at 1 -- just ask many four-year olds. We don't start counting at zero until we learn programming. As a species, we counted from "1" for many millennia before adding zero to the pantheon of numbers.
Counting from 1 is much more intuitive when you are counting rows from tables: "1" for the first row requires little explanation, in particular for people who are not programmers. "0" for the first row requires explanation.
It is easy to forget, but SQL was devised for non-programmers. Much of the verbosity is because it was intended for business users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With