mysql中如何删除表上的索引?删除索引?

ゝ一世哀愁。 2023-02-18 09:50 69阅读 0赞

需求描述:

  今天在做SQL的优化的时候,想要把mysql中某个表上的索引删除掉,突然忘记语法了,找到帮助,在此记录下

操作过程:

1.查看表上的索引

  1. show index from ti_o_sms;

format_png

备注:通过以上的查询,TI_O_SMS_IDX是一个复合索引.

2.删除这个复合索引

  1. drop index TI_O_SMS_idx on ti_o_sms;

format_png 1

备注:执行完删除语句之后,再次查询,表上的复合索引已经被删除了.

3.通过help命令查看删除索引的语法

  1. mysql> help drop index
  2. Name: 'DROP INDEX'
  3. Description:
  4. Syntax:
  5. DROP INDEX index_name ON tbl_name
  6. [algorithm_option | lock_option] ...
  7. algorithm_option:
  8. ALGORITHM [=] {DEFAULT|INPLACE|COPY}
  9. lock_option:
  10. LOCK [=] {DEFAULT|NONE|SHARED|EXCLUSIVE}
  11. DROP INDEX drops the index named index_name from the table tbl_name.
  12. This statement is mapped to an ALTER TABLE statement to drop the index.
  13. See [HELP ALTER TABLE].
  14. To drop a primary key, the index name is always PRIMARY, which must be
  15. specified as a quoted identifier because PRIMARY is a reserved word:
  16. DROP INDEX `PRIMARY` ON t;
  17. URL: http://dev.mysql.com/doc/refman/5.7/en/drop-index.html
  18. mysql>

发表评论

表情:
评论列表 (有 0 条评论,69人围观)

还没有评论,来说两句吧...

相关阅读