How to create and manage Indexes to optimize query performance in MySQL?
Demonstrates creating B-Tree INDEX, UNIQUE INDEX, and composite indexes.
-- Create single-column index for fast search CREATE INDEX idx_last_name ON employees(last_name); -- Create composite index on multiple columns CREATE INDEX idx_name_salary ON employees(last_name, salary); -- Show existing indexes on table SHOW INDEX FROM employees; -- Drop index DROP INDEX idx_last_name ON employees;
Query OK, 0 rows affected (0.02 sec) Records: 0 Duplicates: 0 Warnings: 0 Query OK, 0 rows affected (0.02 sec) Query OK, 0 rows affected (0.01 sec)