I'm applying a database application and that i uses both JavaDB and MySQL as database. I've an ID column during my tables which has integer as type and that i make use of the databases auto_increment-function for that value.

But what goes on after i have more than 2 (or 4) billion posts and integer isn't enough? May be the integer overflowed and continues or perhaps is the best tossed will be able to handle?

Yes, I possibly could switch to lengthy as datatype, but how do you check when that's needed? And i believe there's trouble with obtaining the last_placed_id()-functions basically use lengthy as datatype for that ID-column.

Jim Martin's comment from ยง3.6.9. "Using AUTO_INCREMENT" from the MySQL documentation:

Just just in case there's any question, the car_INCREMENT area /Doesn't WRAP/. When you hit the limit for that area size, Card inserts generate a mistake. (According to Jeremy Cole)

A fast test with MySQL 5.1.45 leads to a mistake of:

ERROR 1467 (HY000): Unsuccessful to see auto-increment value from storage engine

You can test for your error on place and take appropriate action.

You will be aware when it is going to overflow by searching in the biggest ID. You need to change it out prior to any exception measures up to being tossed.

Actually, you need to design having a big enough datatype to start with. Your database performance won't suffer even when you utilize a 64 bit ID right from the start.

Just to soothe the nerves, think about this:

Suppose you've got a database that card inserts a brand new value for whenever a user executes some kind of transaction in your website.

Having a 64 bit integer being an ID then this is actually the condition for overflow: Having a world population of 6 billion then if every human on the planet executes a transaction once per second every single day and each year (without relaxation) it might take a lot more than eighty years for the id to cover.

Ie, only google must vaguely think about this problem from time to time throughout an espresso break.