开发者

what if int data type in mysql reaches limit while insert records?

Although using开发者_运维百科 daily in my programming , but never realized about this question :

since the int(unsigned) data type can hold values from 0 to 4294967295, what actually happens If I declare this INT fields to be auto increment and one morning, it just reaches 4294967295? The obvious answer will be it should throw an error that cannot insert further, but data never stops comin and we have to store the records that still keep commin. What to do in this case?

Also is declaring int(20) will be large enough than this default limit?

Any suggestions?

Thanks.


If you get 4 billion rows, the fact that the field will overflow is probably the least of your problems.

You can declare it to be BIGINT, which holds 8 bytes. Meaning that it will count up to 18446744073709551615.

If it overflows it will go back to 0, and keep inserting, returning an error if a row exists with that number.


Use BIGINT - interval is 0 - 18446744073709551615

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜