Index is a database object, which can be created on one or more columns(max 16 columns).The index will improve the performance of data retrieval and adding.indexes are created in an existing table to locate rows quickly and efficiently.
What is clustered index?
Table can have only one clustered index.In clustered index data’s in table is sorted in particular order based on index keys(either AESC/DESC).In clustered index page chain that holds data pages is also sorted in same order as index keys.So,SQL server follows the page chain in order to retrieve the data rows.By this new rows could be added just by adjusting the links in the page chain without moving entire pages.The leaf nodes of a clustered index contains the data pages with index keys.
What is Non clustered index?
For a table we could have more than one non clustered index because it doesn’t affect data pages organization.The leaf node of a non clustered index does not consist of data pages. Instead, the leaf nodes contain index rows.If we have both the clustered index and non clustered index for a table then index row will have Clustered index key columns that point to the data row. If there is no clustered index then the index row contains Non-Clustered index key columns which is stored along with row locator (or) row identifier.The pointer from an index row to a data row is called a row locator.
Both clustered and non clustered indexes can be unique. That is no two rows can have the same value for the index key. Also we have one special type of index called Non clustered column store index.
Creating a clustered index using Object Explorer:
1.In Object Explorer, expand the table for which you want to create a clustered index.
2.Following window will allow as to select the key columns for index.
3.We could add other options by selecting options node from select page.
4.Click ok.Clustered index will be created.
Create Non-Clustered index using object explorer:
1.Similarly Select Non clustered index from New index.Select the Key columns for an index.
2.In non clustered index we could add included columns for your index.In order to overcome existing index limits.After including needed included columns ,Click ok.
3.Similarly other options could be added by selecting different nodes from select page.
4.Click ok .Index will be created.