What Is Unique Index And Composite Index In Sql?


1 Answers

Tausif Akram Profile
Tausif Akram answered
Index is one of the database objects; index is used for increasing the searching speed of the database. Indexes are usually created on a specific column and this is a column that is mostly used in the where clause of SQL. If only one column is being used for index purposes, that is known as UNIQUE index and if more columns are used for indexing then it is referred to as composite index in SQL.

Index sorts the column accordingly so that when that column is searched then it may return the required record or records very quickly. The best example of Index is that when you buy a telephone diary, then you come across A to Z alphabets on the left side so whenever you are in need of any number you do not search the whole telephone diary ; rather you only go to the first letter of that person's name and thus it makes easier to search. Think of a situation where you have to go through a diary without name indexes, you can imagine how long it would take. In the same way when indexed then databases only go to the first letter and search the relevant record and the query response time is much less.

Answer Question