(1) Set auto-increment
- Option One:
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;
- Option II:
alter table user modify id int auto_increment;
(2) Set the auto-increment starting value
show variables like 'auto_increment%';
set auto_increment_offset=10;
show variables like 'auto_increment%';
(3) Set the auto-increment interval
set auto_increment_increment=10;
show variables like 'auto_increment%';
Note:
How to modify the table name?
alter table old_table rename to new_table;