English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The CREATE INDEX command is used to create indexes in tables (allowing duplicate values).
Indexes are used to retrieve data from databases very quickly. Users do not see indexes; they are only used to accelerate searches./Query.
The following SQL creates an index named 'idx_lastname' on the 'LastName' column of the 'Persons' table:
CREATE INDEX idx_lastname ON Persons (LastName);
If you want to create an index on a column combination, you can list the column names within parentheses, separated by commas:
CREATE INDEX idx_pname ON Persons (LastName, FirstName);
Note:The syntax for creating indexes varies between different databases. Therefore: Check the syntax used to create indexes in the database.
Note:Updating a table using an index takes more time than updating a table without an index (because the index also needs to be updated). Therefore, it is recommended to create indexes only on columns that are frequently searched.