What is clustered and nonclustered index in Sql Server?

Clusters Index:

Clustered indexes sort and store the data rows in the table or view based on their key values. These are the columns included in the index definition. There can be only one clustered index per table, because the data rows themselves can be sorted in only one order.

In SQL Server Clustered indexes store data as a B-Tree Structure and its left node contains the actual values. In clustered index data are physically sorted and stored into the disk and tables. You can create only one clustered index in tables.

CREATE CLUSTERED INDEX Test_TestTable_TestCol1

ON dbo.TestTable (TestCol1);
GO

Non Clustered Index:

In Non Clustered Index’s store data as a B-Tree Structure and its leaf node contains the pointer of the values, leaf lode does contain actual values. In Non Clustered index the logical order of the index does meet the physical order of the row in disk. The Non clustered index structure is often use for finding the data quickly, its enhance the query performance. You can create the multiple non clustered index on the table. The data is stored into the Heap in non-clustered index.

CREATE NONCLUSTERED INDEX Test_Product_ID

ON Purchasing.Product (EntityID);
GO

Leave a Reply

Your email address will not be published. Required fields are marked *

2 + 2 =


All Rights Reserved 2019 | DesignzRush (OPC) Pvt. Ltd.
Inline
Inline