Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Error 1264: out of range value for column

As I SET cust_fax in a table in MySQL like this:

cust_fax integer(10) NOT NULL,

and then I insert value like this:

INSERT INTO database values ('3172978990');

but then it say

`error 1264` out of value for column

And I want to know where the error is? My set? Or other?

Any answer will be appreciated!

like image 876
Cin Avatar asked Jan 11 '13 18:01

Cin


People also ask

How do you fix a column out of range value?

To fix the issue, we will have to store a less than 2147483647 or change the data type of student_ssn_no to BIGINT. Let us modify the column to BIGINT and try inserting the data again. As we can see in the above image, student_ssn_no for row 1 got inserted without any error now.

How do I fix error 1264 MySQL?

To fix the error, change your datatype to VARCHAR . Phone and Fax numbers should be stored as strings.

What is out of range value in MySQL?

When MySQL stores a value in a numeric column that is outside the permissible range of the column data type, the result depends on the SQL mode in effect at the time: If strict SQL mode is enabled, MySQL rejects the out-of-range value with an error, and the insert fails, in accordance with the SQL standard.

What is out of range value?

Out of Range (OOR) Indicators For example, if you have a machine reading that is useful in a range from 10 to 90, you may not know or care if the value is 5 or 6, just know that it is out of range, and may be output by the machine as "<10".


3 Answers

The value 3172978990 is greater than 2147483647 – the maximum value for INT – hence the error. MySQL integer types and their ranges are listed here.

Also note that the (10) in INT(10) does not define the "size" of an integer. It specifies the display width of the column. This information is advisory only.

To fix the error, change your datatype to VARCHAR. Phone and Fax numbers should be stored as strings. See this discussion.

like image 64
Salman A Avatar answered Sep 22 '22 05:09

Salman A


You are exceeding the length of int datatype. You can use UNSIGNED attribute to support that value.

SIGNED INT can support till 2147483647 and with UNSIGNED INT allows double than this. After this you still want to save data than use CHAR or VARCHAR with length 10

like image 20
Saharsh Shah Avatar answered Sep 19 '22 05:09

Saharsh Shah


You can also change the data type to bigInt and it will solve your problem, it's not a good practice to keep integers as strings unless needed. :)

ALTER TABLE T_PERSON MODIFY mobile_no BIGINT;
like image 43
Rohit Kolhekar Avatar answered Sep 20 '22 05:09

Rohit Kolhekar