mysql索引

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;
全部评论

相关推荐

06-26 17:24
已编辑
宁波大学 golang
迷失西雅图:别给,纯kpi,别问我为什么知道
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务