索引的创建
create unique | fulltext | spatial index
index_name
[index_type]
on tb_name(index_col_name,…)
[index_option]
说明
index_type: BETREE | RTREE | HASH
MYLSM 和 InnoDB存储引擎的表默认创建的索引都是BTREE索引
案例
1.在customers表上,根据cust_name和cust_id采用BTREE的索引类型创建一个复合索引
create index index_cust
on customers(cust_name,cust_id);
2.查看索引: show index from tb_name;]
删除索引: drop index index_name on tb_name;
alter table tb_name dropo index index_name;
案例
在表seller的姓名字段上添加一个非唯一索引,取名为index_seller_name
alter table seller
add index index_seller_name(seller_name);