mysql复习第十五天:标识列

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/lw305993897/article/details/102620616

1、标识列(自增长列)

1、一个表只能有一个表示列;
2、表示列只能是数值型;
3、通过设置set auto_increment_increment来设置增长值(步长),可以通过插入来设置初始值;

create table tab_identity(
	id int primary key auto_increment,
	name varchar(10)
);

在这里插入图片描述

insert into tab_identity(name) values('zhangsan');

在这里插入图片描述

  • 修改增长值
show variables like '%auto_inrement%';
set auto_increment_increment=3;
insert into tab_identity(name) values('zhangsan');

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/lw305993897/article/details/102620616
今日推荐