Mysql: What is "AUTO_INCREMENT = 5" in a create table query?

I have a create table query that has the last sentence that says AUTO_INCREMENT=5

Can someone explain what this means? the following is an example of a query to create a MySQL table

 CREATE TABLE IF NOT EXISTS `uploaderdata` ( `id` int(11) NOT NULL AUTO_INCREMENT, `mdn` varchar(13) NOT NULL, `service_request_id` varchar(10) NOT NULL, `carrier` varchar(160) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'CHT', `firstname` varchar(50) NOT NULL, `lastname` varchar(50) NOT NULL, `alt_contactnumber` varchar(13) NOT NULL, `email` varchar(50) NOT NULL, `document_files` longblob NOT NULL, `make` varchar(20) NOT NULL, `model` varchar(100) NOT NULL, `casenumber` varchar(255) NOT NULL, `dated` varchar(255) NOT NULL, `fetched` tinyint(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; 
+7
mysql create-table
source share
3 answers

The auto_increment value of the first record starts at 5 instead of the standard 1 .

id has a constant number for each entry, starting at 5.

+14
source share

read the documentation first. http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

 To start with an AUTO_INCREMENT value other than 1, you can set that value with CREATE TABLE or ALTER TABLE, like this: mysql> ALTER TABLE tbl AUTO_INCREMENT = 100; 
+3
source share

the table already has 4 records, so the next inserted record will take a value in the AUTOINCREMENT field, which is the identifier in your case as 5

+2
source share

All Articles