Does MySQL index foreign key columns automatically? Does MySQL index foreign key columns automatically? database database

Does MySQL index foreign key columns automatically?


Yes, but only on . Innodb is currently the only shipped table format that has foreign keys implemented.


Apparently an index is created automatically as specified in the link robert has posted.

InnoDB requires indexes on foreign keys and referenced keys so that foreign key checks can be fast and not require a table scan. In the referencing table, there must be an index where the foreign key columns are listed as the first columns in the same order. Such an index is created on the referencing table automatically if it does not exist. (This is in contrast to some older versions, in which indexes had to be created explicitly or the creation of foreign key constraints would fail.) index_name, if given, is used as described previously.

InnoDB and FOREIGN KEY Constraints