36

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?

user2864740
  • 60,010
  • 15
  • 145
  • 220
Bejkrools
  • 1,129
  • 2
  • 17
  • 38

1 Answers1

64

KEY is a synonym for INDEX.

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

Check the MySQL documentation for ALTER TABLE.

BlackVegetable
  • 12,594
  • 8
  • 50
  • 82
Kristian Vitozev
  • 5,791
  • 6
  • 36
  • 56
  • I saw that but i didn't know what INDEX|KEY means. Now it's claar, thanx! – Bejkrools Sep 04 '15 at 08:01
  • Glad to hear! You can accept the answer if it was helpful for you. – Kristian Vitozev Sep 04 '15 at 08:41
  • 5
    The claim here is true but the quote from the docs in no way supports it. The MySQL docs use `{foo|bar|baz}` syntax in contexts where `foo`, `bar` and `baz` are *not* synonymous all the time, including on the very same page you've linked to. – Mark Amery Oct 06 '16 at 15:39