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
精彩评论