Search code examples
mysqlcreate-table

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


I have a create table query in which there is a last clause which says AUTO_INCREMENT=5

Could someone explain what does that mean? below is the sample create table MySQL query

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 ;

Solution

  • The auto_increment value of the first record starts with 5 instead of the default 1.

    The id has an ongoing number for each record that starts from 5.