CREATE INDEX

CREATE INDEX is used to create indexes on a table.

An index used to find data quickly, and not have to travel all over the table sequentially in search any particular row.

If a column is a table index, searching for a value in that column, go directly to the corresponding row. The search so much more optimal resources and faster time.

If that were not lookup column index, then we would have to go sequentially the table in search of some data. It is therefore important to create an index for each type of search you want to do in the table.

Update a table with indexes takes more time because you must also update the indexes, so it should only be put indexes on columns that look often.

UNIQUE indexes can be created, ie, indices that do not allow duplicate values.

SQL syntax for CREATE INDEX

CREATE INDEX indexName ON tableName (columnName)

The column is part of this index allows duplicate values ??in your column.

SQL syntax for CREATE UNIQUE INDEX

CREATE UNIQUE INDEX indexName ON tableName (columnName)

The column that is NOT part of this index allows duplicate values ??in your column, because it is a unique key.

Examples of SQL CREATE INDEX

Create the index 'indicepeople' on column 'person' of table 'people'

CREATE INDEX peopleIndex ON people (person)

If we create an index on multiple columns, for example, surname and nickname

CREATE INDEX peopleIndex2 ON people (surname, nickname)