sessions — 2012-08-22T16:52:31-04:00 — #1
I have a ms sql table with 3 columns: id (pk), sku and quantity.
Once a day this table is truncated, then populated with new data. Every time new data goes in, the auto increment id never starts at 1, it keeps incrementing, starting at the highest + 1 pre-truncated id value.
My question is, will it ever stop incrementing, causing insert of new data to stop?
jeff_mott — 2012-08-22T17:26:46-04:00 — #2
If the id (pk) is an int, then it will continue incrementing until 2^32 / 2 - 1, which is 2,147,483,647.
If the id is a bigint, then 2^64 / 2 - 1, which is 9,223,372,036,854,775,807.
And if either the int or bigint is unsigned, then you get double those numbers.
(For some perspective, in order to reach that second number, you'd have to accumulate more than 600 million records every year for as long as the universe has existed.)
sessions — 2012-08-22T17:29:55-04:00 — #3
ok, thanks. yea it's an int. I'm good for a while, every day the tables gets about 3000 new rows
jeff_mott — 2012-08-22T17:32:27-04:00 — #4
In that case, it'll be a couple thousand years before you run out of PKs.
r937 — 2012-08-22T17:49:22-04:00 — #5
nice feature, but it doesn't exist in microsoft sql server
mittineague — 2014-09-18T23:29:14-04:00 — #6
This topic is now archived. It is frozen and cannot be changed in any way.