search

Home  >  Q&A  >  body text

数据库 - MySQL中删除带有索引的字段后,索引会自动删除么?

MySQL表中加一个字段并添加了Index索引,现在把字段删除后对该字段的索引是否还存在?若存在,后期要怎么删除该索引?

附上执行的sql语句:

ALTER TABLE `mytab` ADD COLUMN `is_export`  enum('yes','no') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'no' COMMENT '是否已经导出' AFTER `start_time`;

CREATE INDEX `is_export` ON `mytab`(`is_export`) USING BTREE ;
PHPzPHPz2783 days ago897

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 11:27:54

    http://dev.mysql.com/doc/refman/5.6/en/alter-table.html

    If columns are dropped from a table, the columns are also removed from
    any index of which they are a part. If all columns that make up an
    index are dropped, the index is dropped as well.

    So for your question, after the field is deleted, the index of the field does not exist anymore

    reply
    0
  • Cancelreply