Articles → SQL SERVER → Indexes In SQL Server
Indexes In SQL Server
What Do I Need On My System?
What Are Technical Concepts I Need To Know?
- What are tables in SQL server?
- What is a primary key?
What Is A Database Index?
- Index is a data structure
- Index helps in speeding up the data retrieval operations
- Additional cost and storage space is required to maintain index
Types Of Database Index In SQL Server
- Clustered index
- Non-clustered index
How Physical Sorting And Logical Sorting Are Different
B-Tree
Cluster Index
- Only one clustered index per table
- Data is stored in leaf node of B-Tree. All other nodes contain index rows
- Data is physically sorted
-- Syntax for creating clustered index
CREATE CLUSTERED INDEX index_name ON table_name (column_name)
Non-Clustered Index
- More than one non-clustered index can be implemented on a table
- Leaf node of B-Tree contains the address of data
- Data is logically sorted
-- Syntax for creating non clustered index
CREATE NONCLUSTERED INDEX index_name ON table_name (column_name)