mysql索引分类:
1.普通索引
2.唯一索引
3.全文索引
4.单列索引
5.多列索引
6.空间索引

一.在创建表时创建索引
create table table_name( id int(50) aotu_increment primary key not null, [UNIQUE][FULLTEXT][SPATIAL]INDEX/KEY [别名](属性名(长度 ASC/DESC)) );

ASC:升序 DESC:降序

例:创建普通索引
create table score( id int(11) aotu_increment primary key not null, name varchar(50) not null, index(id ASC), 创建普通索引 );



二.在已经建立的数据表中创建索引

create [UNIQUE][FULLTEXT][SPATIAL] INDEX index_name ON table_name(属性(length ASC/DESC));

在已经建立的表中创建普通索引:
create INDEX stu_info ON studentinfo(id);


三.修改哦数据表结构添加索引

ALTER TABLE table_name ADD [UNIQUE][FULLTEXT][SPATIAL] INDEX index_name ON table_name(属性(length ASC/DESC));


添加普通索引:
alter table studentinfo ADD INDEX timer (time(20));


四.删除索引
DROP INDEX index_name ON table_name;

删除address表中的索引id:
DROP INDEX id ON address;