Add index

MySQL Add index

Add index on MySQL table using alter table syntax.

MySQL Add index syntax

ALTER TABLE table_name ADD INDEX index_name(column_name);

Add index example

ALTER TABLE `books` 
ADD INDEX idx_product_id (product_id);

Output

table `books` altered.