Files
rikako-note/mysql/mysql底层/索引.md
2023-01-10 21:59:13 +08:00

24 lines
955 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# mysql索引
* ## mysql索引的分类
* 从功能逻辑上对索引进行分类:
* 普通索引:只是用于提升查询效率,没有任何的附加约束
* 唯一性索引通过unique关键字可以设定唯一性索引其会限制该索引值必须是唯一的但是允许为null
* 主键索引:特殊的唯一性索引,在唯一性索引的基础上,主键索引还增加了不为空的约束
* 单列索引:作用在一个字段上的索引
* 联合索引:作用于多个字段上的索引
* ## 索引的创建、删除操作
```mysql
# 索引的创建方式
alter table table_name add [unique/index] idx_name (col_name...)
# or
create [unique/index] on table_name(col_name...)
# 索引的删除方式
alter table table_name drop index idx_name
# or
drop index idx_name on table_name
```
* ## 索引的可见性
```mysql
# 通过修改索引的可见性,可以比较创建
```