Determining if MySQL table index exists before creating

前端 未结 7 1768
一向
一向 2021-02-04 14:35

Our system\'s automated database migration process involves running .sql scripts containing new table definitions and their accompanying indexes.

I require the ability t

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-04 15:31

    Use SHOW INDEX FROM mytable FROM mydb; and check if the index is present - each of the returned rows represents one part of an index; the column that would probably interest you most is Key_name, as it contains the name of the index. Documentation here.

提交回复
热议问题