CREATE TABLE `batchinfo` ( `rowid` int(11) NOT NULL AUTO_INCREMENT, `datapath` mediumtext, `analysistime` varchar(50) DEFAULT NULL, `reporttime` varchar(50) DEFAULT NULL, `lastcalib` varchar(50) DEFAULT NULL, `analystname` varchar(150) DEFAULT NULL, `reportname` varchar(150) DEFAULT NULL, `batchstate` varchar(150) DEFAULT NULL, `instrument` varchar(20) DEFAULT NULL, PRIMARY KEY (`rowid`), UNIQUE KEY `rowid_UNIQUE` (`rowid`) ) ENGINE=InnoDB AUTO_INCREMENT=15034 DEFAULT CHARSET=latin1
I want to start the auto incremenet from 20000.
How do I do that? Can I edit the table some how to start incrementing from 20000?
Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table. Often this is the primary key field that we would like to be created automatically every time a new record is inserted.
To change the value of the AUTO_INCREMENT the table must be using the MyISAM engine. So go to the table properties, change the engine from say InnoDB to MyISAM, then change the AUTO_INCREMENT value to whatever should be next in your sequence.
To change a primary key to auto_increment, you can use MODIFY command. Let us first create a table. Look at the above sample output, StudentId column has been changed to auto_increment.
ALTER TABLE batchinfo AUTO_INCREMENT = 20000;
See also Autoincrement
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With