Luiz
Luiz

Reputation: 21

MySQL won't let me insert more than 10 digits using datatype INT

I'm trying to to fill a field with 11 numbers, but MySQL won't let me insert more than 10 digits using datatype INT. I can insert only up to 10 digits. This is the error:

ERROR 1264: Out of range value for column 'cpf' at row 1
SQL Statement:
UPDATE `mercado`.`cliente` SET `cpf`=12345678901 WHERE `cpf`='20'

Anyone knows why?

Upvotes: 1

Views: 5287

Answers (3)

JHS
JHS

Reputation: 7871

The INT type columns you have limit from -2147483648 to 2147483647. If you want to enter values outside of the above range then use BIGINT.

Upvotes: 2

CodeBlue
CodeBlue

Reputation: 350

That's because of data type limit. The range of datatype INT only from -2147483648 to 2147483647. You can use datatype BIGINT instead of. But i think the best way if you working with very big number is use a text datatype (like VARCHAR). If you need number for calculating, just convert it.

Upvotes: 1

cheeken
cheeken

Reputation: 34655

See the MySQL datatype documentation. The maximum value of an INT is 2,147,483,647, which happens to contain 10 digits.

Upvotes: 1

Related Questions