What's the purpose of setting auto_increment to 30 when creating table?

早过忘川 提交于 2019-12-12 03:59:34

问题


CREATE TABLE IF NOT EXISTS `qdz76_piteachers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `teacher_name` varchar(250) NOT NULL,
  `teacher_alias` varchar(250) NOT NULL,
  `teacher_role` varchar(50) NOT NULL,
  `image_folderlrg` int(11) NOT NULL,
  `teacher_image_lrg` varchar(250) NOT NULL,
  `teacher_email` varchar(100) NOT NULL,
  `teacher_website` varchar(250) NOT NULL,
  `teacher_description` text NOT NULL,
  `published` tinyint(3) NOT NULL,
  `ordering` int(11) NOT NULL,
  `teacher_view` tinyint(3) NOT NULL,
  `checked_out` tinyint(1) NOT NULL DEFAULT '0',
  `checked_out_time` datetime DEFAULT NULL,
  `user` int(11) NOT NULL,
  `language` char(7) NOT NULL DEFAULT '*',
  `featured` tinyint(3) NOT NULL DEFAULT '0',
  `metakey` text NOT NULL,
  `metadesc` text NOT NULL,
  `lastname` varchar(250) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=30 ;

I am very new to mysql and have read this page http://dev.mysql.com/doc/refman/5.5/en/create-table.html, it looks like AUTO_INCREMENT = 30 is in table_option section, but I still don't understand what AUTO_INCREMENT = 30 here means. Does it mean all int fields have auto_increment as 30?


回答1:


Actually whenever you prepare a dump from server or get table structure from phpmyadmin then it provide you auto_increment value as per existing table values, so you will be getting it as 30.

Whenever you create new table, then no need to mention auto_increment (if there is no specific reason) as it automatically start from 1.

In some specific reason you need to tell mysql that my auto_increment value should start from this number in this case you need to specify it in your table creation syntax.



来源:https://stackoverflow.com/questions/32708484/whats-the-purpose-of-setting-auto-increment-to-30-when-creating-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!