Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ;
like image 745
Padyster Avatar asked Oct 15 '13 11:10

Padyster


2 Answers

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.

like image 87
juergen d Avatar answered Nov 15 '22 11:11

juergen d


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;
like image 4
Eduard Gamonal Avatar answered Nov 15 '22 11:11

Eduard Gamonal