Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate entry '2147483647' for key 1

Tags:

mysql

Strange problem I can't seem to get my head around. I have a table in a MySQL database with the following structure...

    CREATE TABLE IF NOT EXISTS `tblbaseprices` (
  `base_id` bigint(11) NOT NULL auto_increment,
  `base_size` int(10) NOT NULL default '0',
  `base_label` varchar(250) default NULL,
  `base_price_1a` float default NULL,
  `base_price_2a` float default NULL,
  `base_price_3a` float default NULL,
  `base_price_1b` float default NULL,
  `base_price_2b` float default NULL,
  `base_price_3b` float default NULL,
  `site_id` int(11) default NULL,
  PRIMARY KEY  (`base_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=134 ;

The last base_id I have in there is 132. I assume a couple of records have been deleted to auto_increment is set to 134, as you can see about. I am trying to run the following SQL statement, and when I do, I get the error "Duplicate entry '2147483647' for key 1".

INSERT INTO tblbaseprices (site_id, base_size, base_price_1a, base_price_2a, base_price_3a, base_price_4a) VALUES ('', '', '', '', '', '')

Does anybody have any ideas?

Many thanks!

like image 282
Doyley Avatar asked Aug 11 '11 11:08

Doyley


2 Answers

2^31 − 1 = 2,147,483,647 

The number 2,147,483,647 is ... the maximum value for a 32-bit signed integer in computing

like image 159
arnep Avatar answered Sep 25 '22 01:09

arnep


2147483647 is the largest int value for mysql. Just change the type from int to bigint.

like image 40
user1374 Avatar answered Sep 26 '22 01:09

user1374