Determining if MySQL table index exists before creating

前端 未结 7 1778
一向
一向 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条回答
  •  旧时难觅i
    2021-02-04 15:15

    SELECT INDEX_NAME FROM INFORMATION_SCHEMA.STATISTICS WHERE
    `TABLE_CATALOG` = 'def' AND `TABLE_SCHEMA` = DATABASE() AND
    `TABLE_NAME` = theTable AND `INDEX_NAME` = theIndexName
    

提交回复
热议问题