19

我有一个创建表查询,其中有一个最后一个子句说AUTO_INCREMENT=5

有人可以解释这是什么意思吗?下面是示例创建表 MySQL 查询

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 ;
4

3 回答 3

27

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.

于 2013-10-15T11:25:27.143 回答
4

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;
于 2013-10-15T11:25:39.940 回答
2

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

于 2013-10-15T11:25:37.820 回答