如何在 MySQL 中删除此索引?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1984377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:54:22  来源:igfitidea点击:

How to drop this index in MySQL?

mysqlindexing

提问by user198729

It's created this way:

它是这样创建的:

create table listings(
    id integer unsigned NOT NULL AUTO_INCREMENT,
    accountId  integer unsigned default null,
    title varchar(300) not null,
    country integer unsigned,
    region integer unsigned,
    type integer unsigned,
    price integer,
    unit varchar(20) not null,
    priceUSD decimal(12,2),
    bedrooms integer unsigned,
    thumbnail varchar(100) default null,
    keywords text,
    created datetime,
    deleted boolean default 0,
    fulltext index (keywords),
    PRIMARY KEY (id)
) engine=MyISAM;

How to drop that fulltext index which has no name?

如何删除没有名称的全文索引?

What if the un-named index is:fulltext index (title ,keywords)?

如果未命名的指数是什么:fulltext index (title ,keywords)

采纳答案by Bill Karwin

Run this command in the mysqlclient:

mysql客户端运行此命令:

mysql> SHOW CREATE TABLE listings;

It will show you the DDL for the table, including the system-assigned namefor the index.

它将显示表的 DDL,包括系统分配的索引名称

回答by Haim Evgi

ALTER TABLE listings DROP INDEX keywords;

回答by Yagnesh bhalala

ALTER TABLE {your_table_name} DROP INDEX {your_index_name}

ALTER TABLE {your_table_name} DROP INDEX {your_index_name}

OR

或者

DROP INDEX {your_index_name} ON {your_tbl_name}

DROP INDEX {your_index_name} ON {your_tbl_name}

回答by kimbaudi

You can also get table index information using SHOW INDEXsyntax.

您还可以使用SHOW INDEX语法获取表索引信息。

SHOW INDEX FROM listings;

Also, when you don't provide a name for the index, MySQL will automatically provide a name for the index based on the column(s) being indexed.

此外,当您不为索引提供名称时,MySQL 将根据被索引的列自动为索引提供名称。

For fulltext index (keywords), MySQL will most likely name the index keywords.

因为fulltext index (keywords),MySQL 很可能会命名索引keywords

For fulltext index (title ,keywords), MySQL will most likely name the index title.

因为fulltext index (title ,keywords),MySQL 很可能会命名索引title

I say "most likely" because if there is already an index named keywordsor title, MySQL will name it something else.

我说“最有可能”是因为如果已经有一个名为keywordsor的索引title,MySQL 会将其命名为其他名称。