drop_index.md 1.1 KB
Newer Older
M
Mars Liu 已提交
1 2 3 4
# 删除索引

Joe 想要删除创建在 goods 表创建的索引,但是他已经忘了这个索引的名字,那么他应该怎么做?

M
Mars Liu 已提交
5 6
点击进入[MySQL实战练习环境](https://mydev.csdn.net/product/pod/new?image=cimg-centos7-skilltreemysql&connect=auto&create=auto&utm_source=skill)

M
Mars Liu 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
## 答案

执行

```mysql
show index from goods;
```

查看 goods 表的索引(假设查到是 idx_goods_category),然后执行

```mysql
alter table goods drop index idx_goods_category;
```

## 选项

### A

执行

```mysql
show index from goods;
```

查看 goods 表的索引(假设查到是 idx_goods_category),然后执行

```mysql
alter table goods delete index idx_goods_category;
```

### B

执行

```mysql
show index from goods;
```

查看 goods 表的索引(假设查到是 idx_goods_category),然后执行

```mysql
alter table goods remove index idx_goods_category;
```

### C

执行

```mysql
show index from goods;
```

查看 goods 表的索引(假设查到是 idx_goods_category),然后执行

```mysql
alter table goods drop idx_goods_category;
```