网上搜了半天都没找出个头绪,其他数据到是有,但是mysql里面貌似不能用select查出索引记录,而show index查出来的貌似也不能用where exists来判断,那么就更别提在create index index_name 后面加where了..
    刚刚还想说'在建立索引前判断一下索引是否存在还是很有必要'了.
    但刚才测试了一下,即使在不存在索引的情况下要删除这个索引,虽然有提示出错,但程序还是一样可以正常运行,所以,并没有太大影响.
    不过好歹还是应该有可以判断的方法吧.

解决方案 »

  1.   

    drop index if exists index_name;
    create index index_name ......;
      

  2.   

    不知道你有没有试验过,我在phpmyadmin里面是不能用的.
    我现在在试试在终端里面行不行.
    一样不行,错误如下.我建立的全文索引,索引名为contentmysql> drop index if exists content
        -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use near 'if ex
    ists content' at line 1
      

  3.   

    此外,百度里面有人说,drop index index_name on table 语法是不支持if exists的.