alter table tablename modify filedname int(11) auto_increment ,add primary key (filedname);
tablename替换为表名 ,filedname替换为想要设置递增主键的字段名,11替换为数据长度
本文介绍如何通过SQL语句设置MySQL数据库表中的某个字段为主键并启用自动递增功能。具体步骤包括修改表结构以指定递增主键及添加主键约束。
alter table tablename modify filedname int(11) auto_increment ,add primary key (filedname);
tablename替换为表名 ,filedname替换为想要设置递增主键的字段名,11替换为数据长度
2580
862
1117