当前位置:Gxlcms > 数据库问题 > Mysql索引

Mysql索引

时间:2021-07-01 10:21:17 帮助过:33人阅读

[unique|fulltext|spatial] index 索引名 on 表名 (字段名 [(长度)] [asc|desc]);

或者

alter table 表名 add [unique|fulltext|spatial] index 索引名 (字段名 [(长度)] [asc|desc]);

 2、创建表的时侯创建索引

create table 表名 (
                      字段名 数据类型 [完整性约束条件],
                      字段名 数据类型 [完整性约束条件],
                      ......
                      [unique|fulltext|spatial] index|key [索引名] (字段名 [(长度)][asc|desc])
) engine=myisam;

以上参数详解:

unique:唯一索引,该索引所在字段的值必须是唯一的。

fulltext:全文索引,它只能创建在 char、varchar、text 类型的字段上,而且,现在只有 myisam 引擎支持全文索引。

spatial:空间索引,它只能创建在 geometry、point、linestring、polygon 类型字段上,而且必须声明 not null ,储存引擎为 myisam 引擎。

长度:表示索引的长度。

asc和desc:asc 表示升序排序,desc 表示降序排序。 

 

删除索引

alter table 表名 drop index 索引名;

或者

drop index 索引名 on 表名;

Mysql索引

标签:engine   而且   详解   myisam   text   ble   string   ...   logs   

人气教程排行