1. 索引:index
1.1 普通索引: 这是最基本的索引,他没有任何限制。不会对字段有任何约束,可以为空,不为空
创建索引: create index a on aa(id); 给aa表格的id字段创建普通索引 (key 显示MUL)
查询索引:show index from 表名;
删除索引:alter table 表名 drop index
1.2 唯一索引 :值不能相同,但是可以为空
创建索引: create unique index a on aa(id); (key显示UNI)
查询索引:show index from 表名;
删除索引:alter table 表名 drop index
1.3 主键索引:特殊的唯一索引,不允许有空值,一般是在建表同时创建主键索引
创建索引: alter table 表名 add primary key(id)
later table 表名 add
查询索引:show index from 表名;
删除索引:alter table 表名 drop primary key;
|
|