问题:mysql如何创建索引、删除索引?
解决:使用 create index 方法或者 alter table 方法
方法:
创建普通索引
create index school_id on user(school_id);
或者
alter table user add index school_id (school_id);
创建组合索引
create index name_age on user(name, age);
或者
alter table user add index name_age (name, age);
创建唯一索引
alter table user add unique (name);
创建主键索引
alter table user add primary key (id);
查询创建的索引
show index from user;
删除索引
drop index school_id on user;
或者
alter table user drop index school_id;