Description

The SQL keyword CREATE INDEX is used to create an index on a table.

  • It speeds up the fetch or search operations on table data.
  • It speeds up the fetch operation on a table, but it slows down the update operations as they need to update the index as well along with the update.
  • Always choose the columns that are frequently fetched to create indexes.

The below SQL statement creates an index on the table, using a single column.

Run this on IDE

CREATE INDEX idx_name
ON users (name);

The below SQL statement creates an index on the table, using multiple columns.

CREATE INDEX idx_address
ON users (address, city);

Related Links