What is the difference between "ADD KEY" and "ADD INDEX" in MySQL?

Bejkrools picture Bejkrools · Sep 4, 2015 · Viewed 38.7k times · Source

I dump database and i have one question. What does this query?

ALTER TABLE `ps_cart_rule` ADD KEY `id_customer` (`id_customer`,`active`,`date_to`);
ALTER TABLE `ps_cart_rule` ADD KEY `id_customer_2` (`id_customer`,`active`,`highlight`,`date_to`);

What is diffrence between ADD KEY and ADD INDEX?

Answer

kav picture kav · Sep 4, 2015

KEY is a synonym for INDEX.

... | ADD {INDEX|KEY} [index_name] ...

Check the MySQL documentation for ALTER TABLE.