(1)设置自增
方案一:
CREATE TABLE IF NOT EXISTS `user`(`id` INT UNSIGNED AUTO_INCREMENT,`name` VARCHAR(100) NOT NULL,`sex` VARCHAR(40) NOT NULL,`age` INT(11),PRIMARY KEY ( `id` ))ENGINE=InnoDB DEFAULT CHARSET=utf8;
方案二:
alter table user modify id int auto_increment;
(2)设置自增起始值
show variables like 'auto_increment%';
set auto_increment_offset=10;show variables like 'auto_increment%';
(3)设置自增区间
set auto_increment_increment=10;show variables like 'auto_increment%';
笔记:
如何修改表名?
alter table old_table rename to new_table;