Index
Index
• Parts table does not have a primary key, therefore, SQL Server stores
its rows in an unordered structure.
• When you query data from the table, it needs to scan the whole table
to locate the correct one.
Types of indexes
• SQL Server has two types of indexes:
1. Clustered index
2. Non-clustered index
3. Clustered index: A clustered index stores data rows in a sorted structure based
on its key values. Each table has only one clustered index.
• When you create a table with a primary key, SQL Server automatically creates a
corresponding clustered index based on columns included in the primary key.
Eg:
• The following statement creates a clustered index for the parts table.