mysql:如何从特定点开始自动增量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3470246/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:50:32  来源:igfitidea点击:

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

sqlmysql

提问by l--''''''---------''''''''''''

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

我想从 20000 开始自动增量网络

how do i do that? can i edit the table some how to start incrementing from 20000?

我怎么做?我可以编辑表格一些如何从 20000 开始递增吗?

回答by stacker

ALTER TABLE batchinfo AUTO_INCREMENT = 20000;

See also Autoincrement

另见自动增量

回答by Nick

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;

回答by zneak

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

我不知道如何从CREATE声明中做到这一点,但之后你可以这样做:

ALTER TABLE `batchinfo` AUTO_INCREMENT = 20000;