这是一个 MySQL 表创建的模式。最后一行的AUTO_INCREMENT=3
是什么意思?
CREATE TABLE IF NOT EXISTS `test_b` (
`ID_b` int(10) unsigned NOT NULL AUTO_INCREMENT,
`stuff` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`ID_b`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ;
最佳答案
这会将初始 AUTO_INCREMENT
值设置为 3。因此,第一条插入的记录不是默认从 1 开始,而是从 3 开始。
来自 CREATE TABLE Syntax 上的手册:
The initial AUTO_INCREMENT value for the table.
For engines that support the AUTO_INCREMENT table option in CREATE TABLE statements, you can also use ALTER TABLE tbl_name AUTO_INCREMENT = N to reset the AUTO_INCREMENT value. The value cannot be set lower than the maximum value currently in the column.
我听说过这样的情况,人们从一开始就将此值设置得很大,以使其看起来比一开始实际拥有的内容更多。例如。用户 ID 15,000 与用户 ID 1。
关于mysql - 在 MySQL 模式中, "AUTO_INCREMENT=3"的含义是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11942945/