alter table 表名 add [unique(唯一索引)\fulltext(全文索引)\SPATIAL(空间索引)] index <索引名> on <表名> (属性名【(长度)】【,】);-- 索引名:就是索引的名字,不设置的话就是普通索引。属性名:字段名。长度:指定索引的长度,必须是字符串类型才可以使用
删除索引
sql语句:drop index <索引名> on <表名>;
删除student 表上的 id_name 索引
drop index id_name on student;
王宁使用 SQL语句创建索引来解决问题
create unique index id_sno on student_new(sno);
-- 使用where 语句查询sno=1000000的记录
select * from student_new where sno=1000000;