in reply to Getting first unused integer from a sqlite integer column
You almost never want to “re-use” such a number ... even though it is technically possible. In fact, I don’t even (typically) use autoincrement fields any more. I use randomly-generated strings, long enough to allow me to basically say that every value will be unique. No matter what. No matter many times I run the program or how I slog-up my database.
“All integers look alike,” and y’know, that’s really not such a good thing, after all. But if you now attempt to re-use them, you have just introduced an inherent ambiguity that can never be proofed. The data may become inconsistent, through programmer-error or by any other means, and you can never explain how or when it happened. The data may be incorrect, and it is impossible to (algorithmically) detect it. These are not wise properties for a production system to have.
“Each town ... is very like another when your head’s down over the pieces, brother ...”
-- One Night In Bangkok (from “Chess”)
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting first unused integer from a sqlite integer column
by aquarium (Curate) on Oct 22, 2010 at 03:59 UTC |