Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql int field growing bigger than 11 digits

I have a mysql database, and I am using it as a temprorarily store captcha values. It has a auto incremented id key, with int(11) field. What happens if this value gets bigger than 11 digits?

like image 926
yasar Avatar asked Oct 15 '11 09:10

yasar


2 Answers

A typical INT uses 4 bytes, so it can store the numbers:
Signed: -2147483648 to 2147483647
Unsigned: 0 to 4294967295

A BIGINT uses 8 bytes, so it can store the numbers:
Signed: -9223372036854775808 to 9223372036854775808
Unsigned: 0 to 18446744073709551615

like image 133
Wazy Avatar answered Sep 19 '22 16:09

Wazy


This number (11) has absolutely nothing to do with column range - [SIGNED] INTEGER defines a range (-2147483648 - 2147483647).

Number within parentheses is being used only when combined with ZEROFILL. Then it defines the "length" of displayed number, ie. value 275552 will be returned as string 00000275552.

like image 26
Crozin Avatar answered Sep 17 '22 16:09

Crozin