php - Incorrect Integer (2147483647) is inserted into MySQL?
Solution:
2147483647 is the largest int value for mysql. Just change the type from int to bigint.
Answer
Solution:
Based on your comment of "value being dumped"; the number you are trying to insert is too large for 32-bit systems. The max for 32-bit is 4,294,967,295, and the max for 64-bit is 18,446,744,073,709,551,615. I'd recommend converting your column into a varchar(100)
hash rather than an int, or switch to a 64 bit system. Great article about max ints here, and here.
Also, before I get flamed, be sure to read up on SQL injection in case you are not sanitizing variables being posted directly into sql statements.
Answer
Solution:
While I was playing with SQL and MySQL had the same problem MySQL int data type. Modifying data type from int to bigint fixed issue.
MySQL Integer Types http://dev.mysql.com/doc/refman/5.7/en/integer-types.html
ALTER TABLE tablename MODIFY columnname BIGINT;
Answer
Solution:
Simply Change the data type from INT to BIGINT
Answer
Solution:
The largest value for data type INT is 2147483647. If the number you're inserting is bigger than 2147483647, then it will cause the problem. For solution, change the data type from INT to BIGINT as BIGINT has a maximum value of 9223372036854775807, it might solve your problem. Have a look at this site: https://dev.mysql.com/doc/refman/5.7/en/integer-types.html
Answer
Solution:
The integer type INT is 4Bytes storage, you get from -2^(4*8-1)=-2147483648
to 2^(4*8-1)-1=2147483647
, when you have "signed" flags, if you change the flags to unsigned you will have a range from 0
to 2^(4*8)-1
. MySQL support BIGINT being 8Bytes storage. If you try save a value greater, you will save the max value of the range
Answer
Solution:
Go to operations-> table options -> change increment values to minimum or whatever you want to increment..
the big problem of autoincrement is it's start from last entry by mistake if its very large value then start problem in insert value.. with our predefined datatype
Answer
Solution:
Agree with the datatype change to BIGINT from INTEGER. Currently building a web app with node.js/sequelize the below refactor solved the phone number post from react-redux form manipulated to '2147483647':
clientPhone: {
type: DataTypes.BIGINT,
allowNull: true
},
Answer
Solution:
I had the same problem but not with Varchar. The problem I had was that I was performing an INSERT INTO with a bad order of columns. For anyone who see this maybe is the order of cols that u are using in a subquery
Answer
Solution:
CREATE TABLE `dvouchers` (
`2147483647` int(3) NOT NULL auto_increment,
`code` varchar(12) NOT NULL default '1',
`type` char(1) NOT NULL default '$',
`count` int(3) unsigned NOT NULL default '0',
`amount` int(3) unsigned default '0',
`notes` text,
`expiryDate` date default NULL,
`fkUserAdminId` int(11) NOT NULL default '0',
PRIMARY KEY (`2147483647`),
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Answer
Solution:
Easiest way is change in MySQL "int" to "varchar".
Source