1.创建语句的时候忘记加主键,和主键自增
create table students
(
stud_id bigint(20) not null,
stud_name varchar(255),
stud_class varchar(255)
);
2 增加主键和自动属性
alter table add students change stud_id stud_id bigint(20) not null auto_increment primary key;
如果已经增加了主键,但未设置自动
alter table add students change stud_id stud_id bigint(20) not null auto_increment;
3.增加表的索引,唯一联合索引
create index class_name on `students` (`stud_class`);
create UNIQUE index stud_class_uniq_idx on `student_class_relate` (`stud_id`, `class_id`);
4.修改字段名称
alter table 表名 change 旧名称 新名称 类型及相关属性;
alter table `student_class_relate` change `valid_status` `is_valid` int;
5.删除索引
drop index stud_class_uniq_idx on `student_class_relate`;