CREATE INDEX

Published Aug 22, 2022
Contribute to Docs

The CREATE INDEX command creates an index on one or more existing columns from a table. Indexes cannot be seen by the user of a database; they just help speed up queries.

Syntax

CREATE INDEX index
ON table (column1, column2);

Note: Tables with indexes update slower, so indexes should generally be used on columns that will be searched often but not updated frequently.

Example

This example creates an index called idx_student_name on the student_name column in the students table:

CREATE INDEX idx_student_name
ON students student_name;

All contributors

Looking to contribute?

Learn SQL on Codecademy