即一个索引只包含单个列,一个表可以有多个单列索引
索引列的值必须唯一,但允许有空值
设定为主键后数据库会自动建立索引,innodb为聚簇索引
即一个索引包含多个列
# 查看索引
show index from table_name\G;
# 删除索引
drop index [indexName] on mytable;
# 随表一起创建
create table customer(
...
key(customer_name), # 单值索引
unique(customer_name), # 唯一索引
primary key(customer_name), # 主键索引
key(customer_no,customer_name) # 复合索引
);
# 单独建索引
# 单值索引
create index idx_customer_name on customer(customer_name);
# 唯一索引
create unique index idx_customer_no on customer(customer_no);
# 主键索引
alter table customer add primary key customer(customer_no);
# 复合索引
create index idx_no_name on customer(customer_no,customer_name);
信息加载中,请等待
微信客服(速回)
微信客服(慢回)