mysql: how do i start auto increment from a specific point?

前端 未结 3 1009
予麋鹿
予麋鹿 2020-12-01 07:28
CREATE TABLE `batchinfo` (
  `rowid` int(11) NOT NULL AUTO_INCREMENT,
  `datapath` mediumtext,
  `analysistime` varchar(50) DEFAULT NULL,
  `reporttime` varchar(50)          


        
相关标签:
3条回答
  • 2020-12-01 07:55
    ALTER TABLE batchinfo AUTO_INCREMENT = 20000;
    

    See also Autoincrement

    0 讨论(0)
  • 2020-12-01 07:58

    See the last line of your query:

    AUTO_INCREMENT=15034
    

    Change it to:

    AUTO_INCREMENT=20000
    

    Easy as that! :)

    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=20000 DEFAULT CHARSET=latin1;
    
    INSERT INTO batchinfo (datapath) values('test');
    SELECT * FROM batchinfo;
    
    0 讨论(0)
  • 2020-12-01 08:04

    I don't know how to do it from the CREATE statement, but after that you can do this:

    ALTER TABLE `batchinfo` AUTO_INCREMENT = 20000;
    
    0 讨论(0)
提交回复
热议问题