1.建表时就创建自增列: create table test(id int auto_increment primary key, name varchar(20) not null, password varchar(20) not null); insert into test values(null,'aa','aa'); insert into test values(null,'bb','bb'); 注意:插入语句时,自增列的值为NULL。 2.创建表格后添加: alter table table1 add id int auto_increment primary key 自增字段 一定要设置为primary key.
mysql_ auto_increment
最新推荐文章于 2023-03-04 23:58:21 发布