Since DBs do not reuse numbers of deleted records it is possible to run out of numbers, especially if you pick not really a big integer type for this column.
What would happen and how to prevent it if it's bad?
// SQL Server, MySQL //
No, the primary key does not have to be an integer; it's just very common that it is. As an example, we have User ID's here that can have leading zeroes and so must be stored in a varchar field. That field is used as a primary key in our Employee table.
Primary keys must contain unique values. A primary key column cannot have NULL values. A table can have only one primary key, which may consist of single or multiple fields. When multiple fields are used as a primary key, they are called a composite key.
Every table should have some column (or set of columns) that uniquely identifies one and only one row. It makes it much easier to maintain the data. It's true, without a primary key (or some unique key), you don't have an insertion anomaly if you go to insert the same data multiple times.
Primary Key Can be Zero, but if you set Identity on the column it normally will start at 1 rather than Zero. Primary Key will have Identity Column ..
You end up with a 3+ Hour Downtime, like Slashdot did on their Comments-Function.
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