Indexes in SQL server are similar to the indexes in Books.
They help SQL server retrieve the data quickly.
There are clustered and nonmclustered indexes.
A clustered indexes is a special type of index that records the way in which records in the table
are physically stored.Therefore , table can have only one clustered index.The leaf nodes of a clustered index contain the data pages.
A nonClustered index is a special type of index in which the logical order of the index
does not match the physical stored order of the rows on disk.The leaf node of a non clustered index dows not consist of the data pages .Instead the leaf nodes contain index rows.
The syntax for creating indexes
CREATE INDEX idxModel
ON Product (Model)
Let's assume that we have the following table,
and we want to create an index on the column Last_Name, we would type in,
CREATE INDEX IDX_CUSTOMER_LAST_NAME
on CUSTOMER (Last_Name)
If we want to create an index on both City and Country, we would type in,
CREATE INDEX IDX_CUSTOMER_LOCATION
on CUSTOMER (City, Country)