SQL Index

  • Indexes are special lookup tables. It is used to retrieve data from the database very fast.
  • An Index is used to speed up select queries and where clauses. But it shows down the data input with insert and update statements. Indexes can be created or dropped without affecting the data.
  • An index in a database is just like an index in the back of a book.
  • For example: When you reference all pages in a book that discusses a certain topic, you first have to refer to the index, which alphabetically lists all the topics and then referred to one or more specific page numbers.

1. Create Index statement

It is used to create an index on a table. It allows duplicate value.

Syntax

Example

2. Unique Index statement

It is used to create a unique index on a table. It does not allow duplicate value.

Syntax

Example

3. Drop Index Statement

It is used to delete an index in a table.

Syntax

Example






Latest Courses