Create Index in MySQL with example

Created at 06-Jan-2024 , By samar

To add indexes to columns in a table, you can use the CREATE INDEX statement in SQL. Indexing helps speed up query performance by allowing the database engine to locate and retrieve data more efficiently.

Here's an example of how you can add indexes to the name column in the users table.

CREATE INDEX idx_users_name on users (name);

In above MySQL query:

idx_users_name is the name of the index for the id column.

users is the name of the table.

(name) indicates the column for which the index is created.

Output

mysql> CREATE INDEX idx_users_name on users (name);
Query OK, 0 rows affected (0.62 sec)
Records: 0  Duplicates: 0  Warnings: 0

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.