自增长 auto_increment

auto_increment :自动编号,一般与主键组合使用。一个表里面只有一个自增默认情况下,起始值为1,每次的增量为1。 

例子:
create table tb5(
    id int primary key auto_increment,
    name varchar(20)
)auto_increment =100;

#删除自动增长
mysql> alter table tb5
         -> modify id int;

#增加自动增长auto_increment
mysql> alter table tb5
    -> modify id int auto_increment;

猜你喜欢

转载自www.cnblogs.com/mariobear/p/9180172.html
今日推荐