Hi, I have set up a table in mySQL (see below) and set the pkVoucherId to be auto incremenet and the unique key. The table was functioning correctly by auto incrementing the unique id. Now for some reason it trys to create the unique key of: 2147483647. ...and of course as it needs to be unique it complains about "dupe entry". Does anyone know why it has just started to do this and how to make it start counting from where it left off (2011)? Thanks CREATE TABLE `dvouchers` ( `pkVoucherId` 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 (`pkVoucherId`), UNIQUE KEY `pkVoucherId` (`pkVoucherId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Code (markup):
First Run this Query: and get maximum ID +1: select ifnull(max(announce_id),0)+1 from dvouchers Than Alter table with above number. Change xxx with above query result: ALTER TABLE dvouchers MODIFY pkVoucherId INT AUTO_INCREMENT, AUTO_INCREMENT = xxx ;
Hi, Can anyone explain why this happened? Is it a bug or did I do something wrong? I don't really want it to happen again as it obviously made the site die eeek! Thanks again!