auto_increment是用于主键自动增长的,从1开始增长,当你把第一条记录删除时,再插入第二跳数据时,主键值是2,不是1
create table `test`
(
`id` int(10) not null auto_increment, -- 表示自增列
`name` varchar(20) not null,
primary key(`id`)
)
auto_increment = 1; -- 表示自增起始大小-- 这样就可以创建一个表`test`,id为自增列
-- 执行语句 insert into test (`name`) values ('名字');
-- 就可以插入一行数据为: 1 '名字'
mysql中auto_increment是干什么的?
最新推荐文章于 2024-06-13 16:03:18 发布