This is a schema of a MySQL table creation. What is the meaning of AUTO_INCREMENT=3
on the last line?
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 ;
That sets the initial AUTO_INCREMENT
value to 3. So rather than starting at 1 by default for the first inserted record, it will start at 3.
From the manual on 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.
I've heard cases where people set this value to something large from the beginning to make it seem like they have more content than they really do in the beginning. E.g. user ID 15,000 vs user ID 1.
Apparently it's used to set the starting autoincremented number:
http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
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