mysql创建索引

来源:互联网 发布:企业qq群发软件 编辑:程序博客网 时间:2024/06/14 02:42

索引的创建

1创建表的时候创建

Create table  example(

Id int,

Gread float,

[unique|fulltext|spatial] index|key

[别名] (属性名1[(长度)]  [asc |desc])

);

 

结构:[unique|fulltext|spatial] index|key

[别名] (属性名1[(长度)] [asc |desc]

具体讲解:

Unique:唯一索引

Fulltext:全文索引

Spatial:空间索引

index|key二选一,作用相同

[别名]:可选参数,用来给索引起名字

[(长度)]:可选参数,指定索引长度,只有字符串类型可以使用

[asc |desc]:可选参数asc表示升序排列,desc表示降序排列

 

2已存在的表创建索引

Create [unique|fulltext|spatial] Index索引名 on 表名(属性名1[(长度)] [asc |desc]);

 

3删除索引

Drop index 索引名 on 表名;

原创粉丝点击