求助 MYSQL 如何判断索引是否存在
例如
DROP INDEX IF EXISTS INDEX_NAME  -- 举例,这么写报错!

解决方案 »

  1.   

    DROP INDEX语法不支持这个 IF EXISTS。
    你只能先自己判断,然后再删除。 或者直接删除,然后对捕捉到的异常进行处理。
      

  2.   

    写个sp判断if exists (select index_name from information_schema.statistics where table_name='tb1' and index_name='xxx')
    then drop index xxx on tb1
    end if;